As per Devi Puran, Vishnuji saw baby Karikeya in Parvti's lap, even he wished to be her son, was born as Ganesh. After elephant's head was put on the child's head cut by Shivji, whose body was still alive. Shivjitoo realised this is Vishnuji born as his son.
From Ganesh Puran, Shivji explained about importance of Punyak vrat, that can give a good son. Sanat kumars were purohit. From Magh months Shuklapaksh, trayodashi, her vrat started. With shodashopachar pooja of Narayan. This vrat lasted for almost a year. After compeletion, 1360 Brahmin bhojan, offering 1360 aahutis in yagya & giving simillar nos Gold coins in daan was done.
This vrat was done initially by Manu's wife Shatrupa, she got 2 sons. In Paravti's vrat, Brhmaji with Saraswatij, Indra with Shachi, vishnuji with Lakshmijicame with valuable material required for the vrat. Himavan with his family brought many herbs, Gems, Gold coins etc.
Indra was looking after the daan department, kuber washelping him. Suryadev was the event organiser, Varundev was administering fooddept. Lakshmiji was Annapurna for the event.
When prayed for the Vrat, Narayan told Shivji, it's not easy todo this vrat , needs tremendous resources but when Paravti is doing it, she'll get a son, will be named Ganesh & will be Vighnaharta.
Parvati compeleted all the vidhis. At the end sheasked Sanat Kumars about their dakshina. They asked her husband in dakshina. Parvati was highly disturbed, she fainted. Brhmaji, Vishnuji & other rishis started smiling at her leela. They told Shivji to convince her.
Shivji explained to her aboutimportance of dakshina, if not given immidiately, keeps on multiplying. if not given at all destroys everything. Even Vishnujitold her to give dakshina. Sanat kumars told her either give Shivji or give up the fruit of this vrat along with all the tapasyas you've done till now.
Narayan told them Jagdamba Paravti is the one who gives result of all the vrats & tapasyas. this is her maya. he told Paravti to give Shivji in dakshina, compelete your vrat, then give daan accordingly 7 take him back. Paravti compeleted her vrat giving dakshina.
then requested Sanat kumars, for rishi's importance of a Cow is simillar to my husband. I am giving you 1lakh Cows, please accept them & return my husband back. Sanat kumars said what will we do with Cows, we'll take Trilokinath with us, will roam in the World & let people have his darshan. Paravti was shattered, she was about togive up her body. Suddenly in the Sky a very bight object as bright as many Sun appeared, was very good looking, Parvti wished to have a son like him. She was blesed immidiately.
All the Devas convinced Sanat Kumars to return Shivji & accept the Cows. They did so.
After some times a poor & weak Brahmin came to Paravti's doors, was standing with support of a stik in his hand, asked for food. Paravti asked him what will he have in bhojan. He told her he has heard she has collected various varities of food & materials for her Punyak vrat, give me all, then give water in the end. You feed me so much that my stomach will be Lambodara. Give me lots of Gems, jewellery, good cloths, god's bhakti, mrityunjay's Gyan & many sidhhis. there is nothing impossible for you to get a son.
In every Kalpa, Golokavasi krishna appears as Ganesh in your lap. after saying this that brahmin disappeared. A beaytiful baby boy appeared near her.
Parvti was disturbed seeing that brahmin disappeared. She told Shivjitolook for him. An aakashvani was heared at that time,please calm down & see the son which has appeared due toyour Punyak vrat.
Parvati saw her son was very happy.
This news spread every where. All the Devi Devatas came again to Kailash to bless the child.
Rest of the story is Shani refused to look at the baby fearing his vakra drashti will harm the baby. But Paravti insisted, Shani saw the baby & his head was cut, which merged in Krishna in Goloka. Then Vishnuji cut a baby Elephant's head, joined it with the body of that baby boy.. This is how Ganeshji got an Elephant's head, as per ganesh puran.
Thanks for reading this long story.