I have been expanding my catalog and have run into a few suppliers that are carrying the exact same products. The only difference is the price and stock levels.

To avoid duplicate products on my website (and search engine penalties), I've created a Grouped Product with the name of the product and have added the 2 identical products from the 2 different suppliers and have set them to "Not visible individually"

The problem I now face is that by setting the Associated Products to "Not visible individually" is that the link becomes dead.

What I would like to do is to automatically create a redirect to the Grouped Product for all Associated Products

How do you create redirects of Associated Products to the Grouped Product ?

1 Answer 1


The idea is this. When viewing a product page check to see if the product belongs to a grouped product. If so, redirect to the main product page.
There is a catch. A simple product can be part of more than one grouped product. In this case the simplest approach is to redirect to the first one found.

Here is some code you can use.
Create an extension. Let's call it StackExchange_Grouped.

app/etc/modules/StackExchange_Grouped.xml - the declaration file

<?xml version="1.0"?>
                <Mage_Catalog />

app/code/local/StackExchange/Grouped/etc/config.xml - the module configuration file where you declare an observer for the product view page

<?xml version="1.0"?>

app/code/local/StackExchange/Grouped/Model/Observer.php - the observer that should redirect to the grouped product page.

class StackExchange_Grouped_Model_Observer
    public function redirectToParent($observer)
        $id = Mage::app()->getRequest()->getParam('id');
        $groupedParentIds = Mage::getResourceSingleton('catalog/product_link')
        if (isset($groupedParentIds[0])) {
            $mainProduct = Mage::getModel('catalog/product')
            Mage::app()->getResponse()->setRedirect($mainProduct->getProductUrl(), 301);
        return $this;

Clear the cache and give it a go.

  • wow thanks for the quick reply Marius! Do I need to keep the products visible or I can leave them "not visible individually" ?
    – SR_Magento
    May 13, 2015 at 12:42
  • I'm not sure. I think you can set them invisible because the event is dispatched before the visibility is checked. On the other hand, if the products are not visible I'm not sure the url rewrites are generated for them (but not sure). Test with both visible and not visible and see what comes up.
    – Marius
    May 13, 2015 at 13:44

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.