in Programming, Web Development

How to redirect simple products to grouped product in Magento

For a quick and dirty way of doing this, you can modify the viewAction() on the product controller tested in 1.7,1.8,.19

Make a copy of


and place it in


Modify the viewAction() after this section:

// Prepare helper and params
 $viewHelper = Mage::helper('catalog/product_view');

$params = new Varien_Object();

Add the following:

// Does the product have a parent product?
 $p = Mage::getModel('catalog/product_type_grouped')->getParentIdsByChild($productId);

if(!empty($p)) {

// redirect to parent

$prod = Mage::helper('catalog/product')->getProduct($p[0], null, null);
 header('HTTP/1.1 301 Moved Permanently');
 header('Location: '.$prod->getData('url_path'));


This will give you a 301 redirect to the parent.

Write a Comment