Question

I try many solutions but i can't get the result please help me for getting associated products from grouped productId like for configurable product we use

$parent_pro = $objectManager->create('Magento\Catalog\Model\Product')->load($productId); 
$_children = $parent_pro->getTypeInstance()->getUsedProducts($parent_pro)

How can I get Grouped child products?

Was it helpful?

Solution

Try this

$parent_pro = $objectManager->create('Magento\Catalog\Model\Product')->load($productId); 
$_children = $parent_pro->getTypeInstance(true)->getAssociatedProducts($parent_pro);
foreach ($_children as $child) {
       if ($child->getId() != $parent_pro->getId()) {
        echo "child Id ".$child->getID();
      }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top