Forward to configurable product when opening simple product

Forward to configurable product when opening simple product

October 2, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Forward to configurable product when opening simple product

Configuring Magento: Forwarding Simple Products to Configured Counterparts

In the dynamic world of e-commerce development, it’s common to face scenarios where you need to control how your products are displayed and accessed by customers. One such situation is when you have multiple simple products that share a configurable parent product, and you want to ensure seamless navigation between them.

The Challenge: Navigating Between Simple Products

You’ve set up your Magento store with two simple products—Great Red Cup and Great Blue Cup—and a single configurable product called Great Cup. Both cups are visible in the search results, but clicking on either of them opens the corresponding simple product page instead of the configured counterpart.

Your goal is to implement a mechanism that automatically forwards users from the simple product page to the parent configurable product, with the matching variant preselected.

The Approach: Intercepting and Redirecting Product Views

To achieve this, you’ll need to intercept the product view event in Magento using an observer. This allows you to modify or replace the current product being viewed before it’s rendered on the screen.

Here are the steps involved:

  1. Set up the observer: Create a custom module that observes the catalog_product_view event under the global scope.

    public function observe($observer)
    {
        // Your redirection logic here
    }
    
  2. Check if the product is simple and has a configured parent: Within your observation method, retrieve the currently loaded product ($product) and check its type (via $product->getTypeId()). If it’s a simple product (simple), proceed with the next step.

  3. Find the matching configurable parent: Use Magento’s product collection to find all configurable products that contain the current simple product as an associated variant. If more than one match is found, log an exception and take the first one (as per your requirement).

    $collection = Mage::getModel('catalog/product')->getCollection()->addFieldToFilter('entity_id', array('neq' => $product->getId()))
        ->addAttributeToSelect(array('entity_id'))
        ->addAttributeToFilter('type_id', 'configurable')
        ->addAttributeToFilter('associated_product_ids', array('finset' => $product->getId()));
    
    if ($collection->getSize() > 1) {
        Mage::logException(new Exception('Multiple matching configurable products found'));
        // Handle this situation (you mentioned taking the first one)
    } else {
        $configurableProduct = $collection->getFirstItem();
    }
    
  4. Redirect to the configured product: Now that you have the correct configured product, redirect the user to its URL.

    if ($configurableProduct) {
        $url = Mage::getModel('core/url')->getUrl($configurableProduct->getUrlPath());
        $this->_redirect($url);
    }
    
  5. Preselect the matching variant: To ensure that the correct variant is selected on the configurable product page, you’ll need to pass additional parameters in the URL or use a cookie/session approach.

The Elegant Solution: Passing Variant Information

To preselect the right variant, modify your redirection logic to include the variant attributes as parameters in the URL. This can be achieved by getting the simple product’s attributes and creating a parameter string like color=red&size=m.

$variantParams = '';
foreach ($product->getData() as $attributeCode => $value) {
    if (strpos($attributeCode, 'attribute_') === 0 && !empty($value)) {
        $variantParams .= '&'.substr($attributeCode, strlen('attribute_')).'='.$value;
    }
}

$url = Mage::getModel('core/url')->getUrl($configurableProduct->getUrlPath()).$variantParams;
$this->_redirect($url);

Conclusion

Forwarding simple products to their configured counterparts in Magento requires careful event interception and redirection. By following this approach, you can ensure a seamless user experience while maintaining the flexibility of having multiple variants under a single configurable product.

Remember to thoroughly test your implementation across different scenarios and browsers to ensure compatibility and smooth navigation for your customers.

For more advanced customizations and best practices in Magento development, visit LaravelCompany for expert guidance on e-commerce solutions.

Catalog Extensions Themes Configuration

Our network