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
app/code/core/Mage/Catalog/controllers/ProductController.php
and place it in
app/code/local/Mage/Catalog/controllers/ProductController.php
Modify the viewAction() after this section:
// Prepare helper and params $viewHelper = Mage::helper('catalog/product_view'); $params = new Varien_Object(); $params->setCategoryId($categoryId); $params->setSpecifyOptions($specifyOptions);
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')); exit; }
This will give you a 301 redirect to the parent.
Hi
Why is it “dirty” It works perfect for us.
Best regards
Tomas