Magento – Magento 2 language changes not working properly, Only works for first time when i switch

languagemagento2session

Languages not switching properly. Only works when language parameter www.website.com/?___store=german exits into the url but when i click on the other pages then usually parameter will be removed from url then it's not working.

Any idea guys ?

Thanks in advance!

Best Answer

This is a know Magento bug in version 2.2.0 and 2.2.1 (probably 2.1.X as well).

It has been fixed in v. 2.2.2. so you should upgrade.

As a "quick fix", you can change the core file in /vendor/magento/module-store/block/Switcher.php

Change the function getTargetStorePostData() to:

public function getTargetStorePostData(\Magento\Store\Model\Store $store, $data = [])
    {
        $data[\Magento\Store\Api\StoreResolverInterface::PARAM_NAME] = $store->getCode();
        return $this->_postDataHelper->getPostData(
            //$store->getCurrentUrl(false),
            $this->getUrl('stores/store/switch'),
            $data
        );
    }
Related Topic