Warning: Use of undefined constant wp_cumulus_widget - assumed 'wp_cumulus_widget' (this will throw an Error in a future version of PHP) in /home/blogoptimise/public_html/wp-content/plugins/wp-cumulus/wp-cumulus.php on line 375
Optimise Blog » Magento Tip : Get Grouped Product’s Associated Simple Products on Category Page
Warning: Use of undefined constant style - assumed 'style' (this will throw an Error in a future version of PHP) in /home/blogoptimise/public_html/wp-content/themes/optimblog/functions.php on line 522

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

Written by Gordon

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!