2 (40%) 1 vote

In Magento, there are three product type: bundle, configurable and grouped. They have some children. Today, we will try to get children from product id and try to get parent Ids from product id.

1. Bundle product:

You can take a look at the class Magento\Bundle\Model\Product\Type, it has two functions:

2. Grouped product:

  • You can see the class Magento\GroupedProduct\Model\Product\Type\Grouped:

  • So you can use those class and call the function getChildrenIds or getParentIdsByChild. However, with this solution, you need to know product type. If you don’t know the product type, you can load product and call the function getTypeInstance like this:

The  steps I mention above is the shortest process for you to Get Parent Product Ids in Magento 2. With this guide, you can manage the Product Ids in Magento 2 easily. Every store has a Product Ids in Magento 2 with many attributes.

Thank you for reading this post.

How to Join Product Tables with Custom Table to Get Product Data without Product Collection - Magento 2.3
How to Get Used to Magento 2 Product Options? - Magento 2.3