B-219 Sec-55 Noida, India

How to get a grouped product’s associated products in Magento

This is a question that seems to be asked quite often by new Magento developers.

There is no simple Mage_Catalog_Model_Product::getAssociatedProducts() method, or similar to return all simple products assigned to a grouped product. I outline here how Magento gains access to the collection that we need.



you’ll see that they use this:

    $_associatedProducts = $this->getAssociatedProducts();

Since that .phtml file is of type Mage_Catalog_Block_Product_View_Type_Grouped, we can go to


and see in Mage_Catalog_Block_Product_View_Type_Grouped::getAssociatedProducts() that they have done this:


So we can safely assume that $this->getProduct() returns a product object, and replace it with your $product variable like so:

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

So a total solution would look something like this:

    $products = Mage::getModel(‘catalog/product’)
        ->addAttributeToFilter(‘type_id’, array(‘eq’ => ‘grouped’));
    foreach ($products as $product) {
        $associatedProducts = $product->getTypeInstance(true)->getAssociatedProducts($product);
        // Do something with the $associatedProducts collection

(Visited 61 times, 1 visits today)

Leave a reply

You must be logged in to post a comment.