Recently I met quite a challenge while building an extension for Magento. By default, the urls of simple child products whom belong to a configurable parent are answered with a 404. This behaviour can be easily overridden with a small extension.

Our client wanted to take it a step further. Today we will build an extension that redirects URLs of simple products to their configurable parents with options preselected.

If you’re looking for a tutorial on how to redirect requests to simple product pages to their configurable parent with swatches preselected in Magento 2, please continue reading here.

The XML Basics

Before we start, we need to create the basic files needed for any Magento extension.

Create app/etc/modules/DaanvandenBergh_RedirectSimpleProducts.xml and add the following snippet into it:

That’s it! Our method detects the product ID of the visited Simple Product URL and uses that to detect the ID of its configurable parent. Then it creates an array of all the available options, filters out the ones that are used by the Simple Child Product and sends it along with a 301-redirect.

The biggest upside of this approach is its SEO Friendliness. Since it uses the actual URL of the configurable parent, it doesn’t create any duplicate content. This makes this approach preferable over the approach of some premium plugins.

I hope this extension helps you. It redirects simple product URLs that are not visible in the catalog/search to their configurable parent with its options preselected. If you have any remarks or questions. Please, leave a comment!

Sharp observation! However, it isn’t bad for SEO. It’s a much requested feature by merchants. Here’s how it works:
– The sitemap contains a list of all simple product URLs
– The Google bot crawls each of these URLs and essentially lands on the same page
– After this, you should rewrite your canonical URL to the simple product’s URL to tell the crawler to index the Simple Product’s URL instead of the configurable products’ URL. And for example, rewrite the meta title of the page “Purple T-shirt XXL”, instead of just “T-shirt”. But this is beyond the scope of this article. I can jump into it another time, perhaps.

Choose Amount:

Personal Message:

Wake me up in case of:

This website uses cookies to display contextual advertising for users in the European Economic Area (EEA). No personal information is collected in this process. For users outside the EEA we use cookies to display personal advertising. If you want to know more or withdraw your consent to all or some of the cookies, please refer to the privacy policy. By closing this banner or continuing to browse otherwise, you agree to the use of cookies.DismissPrivacy Policy