Magento Tip : Get Grouped Product’s Associated Simple Products on Category Page

Written by Sid Vel

Topics: Magento

Here is a simple trick to get the sub-products of a grouped product on the category products listing page. Add the following code to the products list.phtml file.

$_associatedProducts = array();
if ($_product->getTypeId() == 'grouped')
{
$_associatedProducts = $_product->getTypeInstance(true)->getAssociatedProducts($_product);
}

Once you collect all simple product data associated with the grouped product, you can loop through the array and display the simple product’s data.

5 Comments Comments For This Post I'd Love to Hear Yours!

  1. Ryodin says:

    Great post, thank you.

  2. erwik says:

    great but in fact I just want to do the opposite.
    I mean, I have one or more products and I want get the grouped product, thanks

  3. josh says:

    Hi could you tell where in this file i need to add this code

    cheers

  4. Sid Vel says:

    Within your template directory, you will find the Catalog/Products/List.phtml file.

Leave a Comment Here's Your Chance to Be Heard!