How to get the array of associated product of group product in magento?

For get the array of associated product of group product in magento you to add simple this line in code where you are getting group product details.

$associatedProducts = $_product->getTypeInstance(true)->getAssociatedProducts($_product);

print_r($associatedProducts);

it will return to you all associated products array of group product now you can use this array as you want.

and you want to get the associated product ids only
then you can simple add this like below above code



foreach($associatedProducts as $assoc_id)
{
$aid = $assoc_id->getId();
echo "id of associated products is = ".$aid;
echo "<br/>";
}

Comments