Magento 2.2 – Fix Store View Switch After Upgrade

magento2.2magento2.2.0store-switcherstore-view

Since I have upgraded my website to Magento 2.2.0 (from 2.1.9), the store view switch stopped working on all the pages save for the homepage and the contact page.

I have 2 store views for 2 languages, and whenever I am on a page and I try to switch to the other language version of that page, I get a 404.

How to make this switcher work again?

Best Answer

As @mkotov writes.. the issue is tracked and solved.

For now, if you want, you could go in

magento2/app/code/Magento/Store/Model/Store.php (Magento installation by Github)

or

vendor/magento/module-store/Model/Store.php (Magento installation by composer)

and replace the second row in

public function getCurrentUrl($fromStore = true)

$requestString = $this->_url->escape(ltrim($this->_request->getRequestString(), '/'));

with

$requestString = $this->_url->escape(
    preg_replace(
        '/\?.*?$/',
        '',
        ltrim($this->_request->getRequestString(), '/')
    )
);
Related Topic