How to Get Parent Product ID in Magento 2

How to Get Parent Product ID in Magento 2

The post shows the programmatic method to get parent product ID in Magento 2. Magento 2 has 3 product types named configurable, bundled and grouped, those have children products. You might be wondering if you can get parent product ID of these 3 product types.

You can use the solution if you are selling the store products on 3rd party platforms like Facebook shop and care to enhance the shopping journey.

For example, I used the below method for a client who wanted to redirect the customers to the website directly on the cart page from Facebook shop product. And the product had to be already added to the cart. The customer can skip the step to manually add the product to the cart in the Magento 2 store. However, to implement it, I needed to get the parent product ID as the simple product configuration can’t be displayed.

Hence, the solution:

Method to Get Parent Product ID in Magento 2:

That’s it.

Mention your doubts in the Comments section below and I’d be happy to solve them for you.

Feel free to share the post with fellow developers on social media.

Thank you.

Get Weekly Updates

Never miss Magento tips, tricks, tutorials, and news.

Thank you for subscribing.

Something went wrong.

(based on 5 Reviews)

Sanjay is a co-founder at Meetanshi. He is a Certified Magento Developer who loves creating Magento E-commerce solutions. Owing to his contributions in Magento Forums and posting solutions, he is among the top 50 contributors of the Magento community in 2019. When he is not engrossed with anything related to Magento, he loves to play cricket.

Leave a reply:

Your email address will not be published.