Magento2: Magento 2.2 language switching not working on catalog and Product Pages

Created on 2 Nov 2017  ·  28Comments  ·  Source: magento/magento2

Preconditions

  1. Magento Clean Install 2.2
  2. More than one store views English and Greek

Steps to reproduce

  1. got o this page: https://www.nuovamoda.fashion/el/papoutsia/mpotes.html
  2. Try To change Language

Expected result

  1. Go to desired Language

Actual result

  1. Stay in the same Language
Fixed in 2.2.x Clear Description Confirmed Format is valid Ready for Work Reproduced on 2.2.x Reproduced on 2.3.x

Most helpful comment

Maybe this helps someone...
We needed to add an extra parameter (___store) to the fix from @klimart to make it work (in 2.2.1)
/home/www/nahrin/htdocs/vendor/magento/module-catalog/Controller/Product/View.php: Line 79

if ($this->getRequest()->isPost() && $this->getRequest()->getParam(self::PARAM_NAME_URL_ENCODED) && !$this->getRequest()->getparam('___store')) {

/home/www/nahrin/htdocs/vendor/magento/module-catalog/Controller/Category/View.php: Line 155

if ($this->_request->getParam(\Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED) && !$this->getRequest()->getparam('___store')) {

All 28 comments

Tested it on a clean Magento 2.2 installation with another store view configured and "Add Store Code to Urls" enabled. It works fine in "development" mode, but doesn't work in "production" mode.

Hi Mhauri
Thanks for your Response and your time
Is it Possible to be fixed?
Thanks In Advance

Hello @iWEBproject. Thanks for reporting. Would You please provide us detailed steps of how You set two store views.

Hello
Yes of course I will try to describe

  1. I upload compressed file el_GR.zip and Unzip in to this path: app/i18n/mageplaza/el_GR/
  2. I Flush Magento Cache
  3. I set up the store Views For English and Greek (I set up Greek as default) See Images also
    stores
    sores 2
  4. I change URL Options (was not working Corrct before I do That) see image
    url options
  5. I Flush Magento Cache
  6. I duplicate blogs and pages for both languages
    Done

@iWEBproject, thank you for your report.
We've created internal ticket(s) MAGETWO-83549 to track progress on the issue.

The same problem here in fresh install of 2.2.1 with Stores > Configuration > Web > Url Options > Add Store Code to Urls = Yes.

I have the same issue with 2.2.1 version.

Hope a solution.

I see that the issue is fixed on you website https://www.nuovamoda.fashion/el/papoutsia/mpotes.html. How can i fix it please?

thank you in advance.

Hi achatpc
Is not fixed my friend I wish....
go and check: https://www.nuovamoda.fashion/el/papoutsia/mpotes

The same in 2.2.1, buth in production and developer modes.

The issue occurs in these places:

vendor/magento/module-catalog/Controller/Category/View.php
    public function execute()
    155: if ($this->_request->getParam(\Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED))

vendor/magento/module-catalog/Controller/Product/View.php
    public function execute()
    79: if ($this->getRequest()->isPost() && $this->getRequest()->getParam(self::PARAM_NAME_URL_ENCODED))

Not completely sure if it should be the correct fix, but additional condition like && !$this->getRequest()->getParam('___from_store') can resolve this issue

vendor/magento/module-catalog/Controller/Category/View.php
    public function execute()
    155: if ($this->_request->getParam(\Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED) && !$this->_request->getParam('___from_store')) {

vendor/magento/module-catalog/Controller/Product/View.php
    public function execute()
    79: if ($this->getRequest()->isPost() && $this->getRequest()->getParam(self::PARAM_NAME_URL_ENCODED) && !$this->getRequest()->getParam('___from_store')) {

Thank you I will test it and provide feedback for you.

Have a nice day

Envoyé de mon iPhone

Le 15 déc. 2017 à 23:11, Artem Klimov notifications@github.com a écrit :

The issue occurs in these places:

vendor/magento/module-catalog/Controller/Category/View.php
public function execute()
155: if ($this->_request->getParam(MagentoFrameworkAppActionInterface::PARAM_NAME_URL_ENCODED))

vendor/magento/module-catalog/Controller/Product/View.php
public function execute()
79: if ($this->getRequest()->isPost() && $this->getRequest()->getParam(self::PARAM_NAME_URL_ENCODED))
Not completely sure if it should be the correct fix, but additional condition like && !$this->getRequest()->getParam('___from_store') can resolve this issue

vendor/magento/module-catalog/Controller/Category/View.php
public function execute()
155: if ($this->_request->getParam(MagentoFrameworkAppActionInterface::PARAM_NAME_URL_ENCODED) && !$this->_request->getParam('___from_store')) {

vendor/magento/module-catalog/Controller/Product/View.php
public function execute()
79: if ($this->getRequest()->isPost() && $this->getRequest()->getParam(self::PARAM_NAME_URL_ENCODED) && !$this->getRequest()->getParam('___from_store')) {

You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.

hi @klimart thanks for the solution. i have implemented your solution in my magento 2.2.1 and it is not working. i have tested this solution on "default", "developer" and "production" mode as well.
@p-bystritsky hi, do you have any update regarding this issue ? thanks

Hello @irfanMukhtar it's seems strange, as for me fix works in 2.2.2 version, but I don't observe any core code changes in these files from 2.2.0 version, so it should work for 2.2.1 and 2.2.0 too.
I've created git patch for this issue with my changes
https://github.com/klimart/magento2-patches/blob/master/patches/11963-language-issue.patch

Thanks a lot @Klimart. I have implemented you patch in my magento 2.2 and it is working fine. Now language is switching on catalog and product page. Great work 👍

Can also confirm it works fine on 2.2-develop branch.

Maybe this helps someone...
We needed to add an extra parameter (___store) to the fix from @klimart to make it work (in 2.2.1)
/home/www/nahrin/htdocs/vendor/magento/module-catalog/Controller/Product/View.php: Line 79

if ($this->getRequest()->isPost() && $this->getRequest()->getParam(self::PARAM_NAME_URL_ENCODED) && !$this->getRequest()->getparam('___store')) {

/home/www/nahrin/htdocs/vendor/magento/module-catalog/Controller/Category/View.php: Line 155

if ($this->_request->getParam(\Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED) && !$this->getRequest()->getparam('___store')) {

Hi klimart and Happy New Year
I just Modify both View.php in the paths you described
Result Product Page Is working
Category Page is not working
Version Of Magento is Clean 2.2.2
https://www.nuovamoda.fashion/el/gynaikeia-papoutsia/mpotes.html

2.2.2, the same. Applied klimart's patch but language not switched - page simply reloading to the same lang when "Add Store Code to Urls" is on.

I also confirm the @klimart patch is working on 2.2.2. Thanks!

@moleculech Tested with 2.2.1 and working fine in category and product put not working in catalog search result.

I can also confirm this is a problem in 2.1.11
Will try the suggested fix from above

I can confirm the issue in 2.2.2 and also that the fix posted by @klimart and in the 13534 pr resolves the issue. I didn't test catalog search results prior to patching my site but I am able to use the language switcher properly on catalog search results (as well as category pages and product detail pages) after the patch.

I really hope this makes it into 2.2.3 as it's a "big deal" IMO :)

//anyone not successful with the patch here probably just needs to flush their caches/static-view/preprocessed files

Hi @iWEBproject. Thank you for your report.
The issue has been fixed in magento-engcom/magento2ce#1143 by @p-bystritsky in 2.2-develop branch
Related commit(s):

  • 2025c55b356de92a7800705c5a3898f6eb33ac23
  • 719111f18a009ee01ff8196746779b60c332f639
  • ef1a7ded4e3c4a8f72d832cba7278b14b7799a79
  • b0c224efcbae7b46d8a441668cf2418cceef1e9f
  • 4ca46ae385aeacd18f560c228b46b21c3b8522b7

The fix will be available with the upcoming 2.2.4 release.

I can confirm the same issue on 2.1.12 and that the fix provided by https://github.com/magento/magento2/issues/11963#issuecomment-355043121 has fixed the issue.

Is there a backport planned for 2.1? Or another ticket tracking this?

Hi, it seems to me that the above mentioned fix by @klimart does only work with products and categories that have the same URL key in both stores.
Did anyone get it working with different url keys?

Update

Maybe worth noting:
Magento\Store\Block\Switcher::getTargetStorePostData()
changing getCurrentUrl(false) to getCurrentUrl(true) did the trick for me and now adds nice rewritten URLs to the language switcher. The patch above is not required for this solution. One problem may be that it adds "___from_store=xx" to catalogsearch-URLs, presumably because they don't have a rewrite. Magento v 2.1.14

Hi, has this been backported to 2.1 already?

Was this page helpful?
0 / 5 - 0 ratings