404 Not Found When Displaying Product in Different Store View

magento-2.1productproduct-pagestore-view

I get 404 not found when display the product in different store view and when pressing back it gives the product display page.

It happens with products in 3rd level sub category, despite working fine in 1st and 2nd level categories.

Steps to reproduce in our store:

1- Navigate to 3rd level category page

2- Click on any product to view its page.

3- Switch the store view to see the product in other store view
"عربى/English" you will get 404 Not found.

4- Click the browser back button you will see the product display page
of the store view.

Do the same for any 1st or 2nd level catogry it works fine without 404 errors

What is the reason for that issue in order to fix or where to find in logs, I checked debug, error, system logs files and didn't find any thing related.

Thanks in advance

Best Answer

It looks like the bug is in the plugin \Magento\UrlRewrite\Block\Plugin\Store\Switcher\SetRedirectUrl which is declared in /vendor/magento/module-url-rewrite/etc/frontend/di.xml.

You can simply disabled the plugin by changing line 21 to:

<plugin disabled="true" name="setStoreSpecificRedirectUrl" type="Magento\UrlRewrite\Block\Plugin\Store\Switcher\SetRedirectUrl"/>

I don't think you can remove a plugin by using a custom module so I think editing the core file is the only way unfortunately. I don't know what the repercussions from disabling this plugin are, but it does solve your problem.

Related Topic