0

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?

0

1 Answer 1

2

Try this

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$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();
      }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.