It is possible to define a different template in my layout xml for simple products that are a child of a grouped product compared to a stand-alone simple product?

In my current store the "child" products pull information from the parent which obviously cannot be the case for stand-alone products. The only other alternative I can see is to put a whole load of IFs all over the place based on whether the product has a parent using getParentIdsByChild($product->getId())

1 Answer 1


You can create a new layout handle, let's call it <product_child_of_grouped> that you can load only if the product is part of a grouped product.
in your product_child_of_grouped layout handle you can do this:

    <reference name="product.info">
        <action method="setTemplate">

Then you can rewrite the method Mage_Catalog_Helper_Product_View::initProductLayout() and tell Magento to load your layout handle if the product is part of a grouped product.

after the line $update->addHandle('PRODUCT_' . $product->getId()); add this

if ($product->getTypeId() == 'simple') {
    $parentGrouped = Mage::getResourceSingleton('catalog/product_link')
            ->getParentIdsByChild($product->getId(), Mage_Catalog_Model_Product_Link::LINK_TYPE_GROUPED);
    if ($count($parentGrouped)) {
  • Cheers Marius good tip. I think that is the best way to achieve it. Thanks for the quick response. Mar 7, 2016 at 16:06
  • You can add layout handles via controller_action_layout_load_before event. No rewrite necessary. See Creating Custom Layout Handles for more information.
    – mam08ixo
    Mar 10, 2016 at 9:19
  • 1
    @mam08ixo. I agree, but that event gets dispathced for all the pages. There is no point in adding an overhead on every page just to check if the current product is grouped.
    – Marius
    Mar 10, 2016 at 9:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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