I need to detect if product is associated product of grouped product and if it is get this grouped product. Can anyone help me with it?

  • You mean, if the product is associated with any grouped product then get the parent grouped product? Or do you want to know if the current product is a grouped product then get all of its associated products – TBI Infotech Jun 11 '14 at 8:51
  • @TBIInfotech, first. if the product is associated with any grouped product then get the parent grouped product – Alex K Jun 11 '14 at 8:52

Let's say you have the product in question $product.
Try this:

$groupedParentsIds = Mage::getResourceSingleton('catalog/product_link')
                   ->getParentIdsByChild($product->getId(), Mage_Catalog_Model_Product_Link::LINK_TYPE_GROUPED);

Now that you have the parent ids you can easily get the product instances using



$parents = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*')->addAttributeToFilter('entity_id', array('in'=>$groupedParentsIds))
  • works perfect!! – jruzafa Jun 20 '16 at 9:29

Get Current product Id say $id

if($productType == "simple"){
    $parentIds = Mage::getModel('catalog/product_type_grouped')->getParentIdsByChild($id); // check for grouped product
  1. use product_id to get the group parents ids

$_grouped_parents_id = Mage::getModel('catalog/product_type_grouped') ->getParentIdsByChild($_product->getId());

2. Iterate the $_grouped_parents_id to reload the group product by the id.

foreach($_grouped_parents_id as $_product_id) {
           $group_product = Mage::getModel('catalog/product')->load($_product_id);  
        $associated_products = $group_product->getTypeInstance(true)->getAssociatedProducts($group_product);
  • I have checked it but not got all associated, can you please verify it again, and share the output. – Ami Kamboj Jun 11 '14 at 9:13
  • 1
    I added the code how to get the associated products by group product id. The output of $_grouped_parents_id is an array. – Amier Jun 11 '14 at 10:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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