1
  1. In language switcher when i switch from the default storeview (French in my example) to English, the url changes to: https://example.com/?___store=en
  2. Using the language switcher in the header, switch again from English to French, the url changes to: https://example.com/?___store=en?___store=fr and the shop crashes
1

Go to vendor/magento/module-store/Model/Store.php

Change this line from:

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

to:

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

You can find this line on 1139

This is magento2.2 default issue

0

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(), '/')
    )
);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.