magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.47k stars 9.28k forks source link

Upgraded to Magento 2.2.4 from Magento 2.1.9 - Locale and Store Configuration issues 'Store View' Locale not being used on frontend, 'Default Config' Locale being used instead #15205

Closed callumstar closed 6 years ago

callumstar commented 6 years ago

Magento multi-store installations aren't using the store view specific values from the Store Configuration if they have been set to be different to the global 'Default Configuration'.

Preconditions

  1. Magento 2.2.4
  2. Multi-storefront installation
  3. PHP 7.0.28

Steps to reproduce

  1. Set global locale in Store Configuration in the admin (e.g. 'English (United Kingdom)')
  2. On one of the individual storefronts in the Magento installation, set locale to be different value to the global (e.g. 'French')
  3. Save configuration and then review frontend.

Expected result

  1. Locale should be using 'fr-FR' and the lang attribute should be set to be 'fr'.
  2. Translations should be using the 'French' locale

Actual result

  1. The frontend shows all storefronts in the global locale ('English') instead of using the storefront specific value.
  2. This means that all different language storefronts use 'English' and not their respective languages.
callumstar commented 6 years ago

Further to the above, we have done some further research and no other language apart from en_GB gets compiled in the 'pub/static/' folder regardless of what language/locale we have set.

LSERRE commented 6 years ago

I got the same issue in 2.2.4, Default locale configuration is used for all stores view. This issue is really big.

andy17612 commented 6 years ago

I tested others language, like Chinese , Japanese it can showing the language. *But something error on frontend , my theme some file is losed. On english frontend is working.I already changed file 777 . Ran update,compile or static-content:deploy , something are not working still.

callumstar commented 6 years ago

Hi @magento-engcom-team / @magento-team,

Is there any reponse on this at all? It seems to be a pretty fundamental issue for users with multi-store websites and one that doesn't look to have been tested overly well by yourselves. It looks like the "Default Configuration' is used for all store views when loaded regardless if you have chosen to 'Use Default Values' or not.

I'm seeing similar issues now appear in the Issue Tracker:

hostep commented 6 years ago

@callumstar: I tried to reproduce this on a cleanly installed 2.2.4 but couldn't reproduce (sorry, didn't test upgrading from 2.1.9), I performed following steps:

Can you try to provide clear steps to reproduce the issue (preferably on a clean install of 2.2.4)?

Additional thing you can check, check the files app/etc/config.php and app/etc/env.php and see if they contain a value for locale, because if it is defined in there, it will overwrite the value defined in the database (this is a new feature in Magento 2.2).

callumstar commented 6 years ago

Hi @hostep,

I did some further digging after your testing and I agree that this changes the locale on the frontend if you change the values for the 'Default' store (the store you have assigned as the default store view).

However, you missed a critical step, you need to have multiple storeviews not just 1 storeview. If you change the values for the 'Default' store then it is fine. I just tested changing the 'Default' storeview and it works as expected (I switched the locale to IT and it changed it to IT) but then tried changing another storeview with the locale of FR and this then kept the IT value.

The issue is with having multiple storefronts not just a single 'Default Store View'.

I did also check the env.php and config.php files and both do not have the locale value set in them.

LSERRE commented 6 years ago

Yes I agree with @callumstar. Moreover the problems occurs only in production mode I think.

hostep commented 6 years ago

Ok thanks for the additional information!

I'll do some more testing later on. If this is turns out to be a new bug, then I don't recommend anyone upgrading to 2.2.4, because it would be a huge problem (issue #15245 also sounds like a complete disaster and will trigger all kinds of unexpected things to happen).

hostep commented 6 years ago

Alrighty, I was able to reproduce, interestingly enough it only happens when you have multiple websites, if you only have a single website but multiple stores or storeviews, the problem doesn't trigger.

So here are the steps to reproduce:

  1. Setup a clean Magento 2.2.4 installation using composer
  2. Run composer require imaginaerum/magento2-language-fr-fr
  3. Run bin/magento setup:upgrade
  4. Go to Stores => All Stores => Create Website
  5. Name: Non Default Website, Code: non_default_website, Sort order: 10
  6. Go to Stores => All Stores => Create Store
  7. Web Site: Non Default Website, Name: Non Default Store, Code: non_default_store, Root Category: Default Category
  8. Go to Stores => All Stores => Create Store View
  9. Store: Non Default Store, Name: Non Default Store View / Code: non_default / Status: Enabled, Sort Order: 10
  10. Go to Stores => Configuration => General => Web => Url Options
  11. Set 'Add Store Code to Urls' to 'Yes' & Save Config
  12. Go to Stores => Configuration => General => General
  13. Switch to the Store View: 'Non Default Store View'
  14. Change Locale to 'French (France)' & Save Config
  15. Flush all caches
  16. Go to the frontend to http(s)://domainname/default
  17. You'll see everything in English: good expected!
  18. Now go in the frontend to http(s)://domainname/non_default
  19. You'll see everything in English: not good, unexpected, should be French
  20. In the backend, go to Stores => All Stores => Non Default Website
  21. Check 'Set as Default' and Save Web Site
  22. Repeat the frontend testing, and everything is reversed now, both storeviews now show up in French

So basically this is the same issue as reported in #15245, it's only with a different configuration. I tested with a couple of other configurations changed on the non-default storeview and all of them are getting ignored and the ones from the default website are taken. So this is a huge problem.

Following @jokeputs advice from #15245 to try and see if reverting commit https://github.com/magento/magento2/commit/c18e36b804fb3c86caa39d9976ce5db7497001a7 also fixes this problem, and yes it does (but this is most likely not the correct way of fixing this).

@magento-engcom-team: this is a very serious issue, I really hope you can prioritise this and make sure it gets fixed in 2.2.5

sidolov commented 6 years ago

Hi @callumstar. Thank you for your report. The issue has been fixed in magento/magento2#15929 by @fmarangi in 2.2-develop branch Related commit(s):

The fix will be available with the upcoming 2.2.6 release.

hostep commented 6 years ago

Let's quote from the PR to provide more accurate info:

fix will be available in 2.2.5 release. The comment above was autogenerated due to delivery to 2.2-develop branch, the changes were delivered to 2.2.5 release line in the separate internal pull request

VladimirZaets commented 6 years ago

Hi @callumstar. Thank you for your report. The issue has been fixed in magento/magento2#16046 by @hitesh-wagento in 2.3-develop branch Related commit(s):

The fix will be available with the upcoming 2.3.0 release.

EliasKotlyar commented 6 years ago

I posted a solution for everyone who are not patient enough to wait until 2.3 here: https://github.com/magento/magento2/issues/15245

Ctucker9233 commented 5 years ago

Doesn't look like it was shipped out as of 2.2.6 either. The fixed code doesn't appear in 2.2.8. I know code quality is extremely important, but the time to release fixes seems a little ridiculous.

hostep commented 5 years ago

@Ctucker9233: this was definitely fixed in 2.2.5. And 2.2.8 also contains the changes. Are you sure you are talking about the correct problem here? Any steps you can provide to reproduce on 2.2.8?

Ctucker9233 commented 5 years ago

@hostep I'm just comparing code. I don't see this code in any variation in the 2.2.8 code. I'll double check to make sure.

Ctucker9233 commented 5 years ago

@hostep Yes it is there. I just didn't see it. Not an issue then.

dharmendrak2019 commented 4 years ago

Package zendframework/zend-stdlib is abandoned, you should avoid using it. Use laminas/laminas-stdlib instead. Package zendframework/zend-mime is abandoned, you should avoid using it. Use laminas/laminas-mime instead. Package container-interop/container-interop is abandoned, you should avoid using it. Use psr/container instead. Package zendframework/zend-validator is abandoned, you should avoid using it. Use laminas/laminas-validator instead. Package zendframework/zend-loader is abandoned, you should avoid using it. Use laminas/laminas-loader instead. Package zendframework/zend-mail is abandoned, you should avoid using it. Use laminas/laminas-mail instead. Package zendframework/zend-escaper is abandoned, you should avoid using it. Use laminas/laminas-escaper instead. Package zendframework/zend-uri is abandoned, you should avoid using it. Use laminas/laminas-uri instead. Package zendframework/zend-diactoros is abandoned, you should avoid using it. Use laminas/laminas-diactoros instead. Package zendframework/zend-http is abandoned, you should avoid using it. Use laminas/laminas-http instead. Package zendframework/zend-psr7bridge is abandoned, you should avoid using it. Use laminas/laminas-psr7bridge instead. Package zendframework/zend-hydrator is abandoned, you should avoid using it. Use laminas/laminas-hydrator instead. Package zendframework/zend-servicemanager is abandoned, you should avoid using it. Use laminas/laminas-servicemanager instead. Package zendframework/zend-filter is abandoned, you should avoid using it. Use laminas/laminas-filter instead. Package zendframework/zend-inputfilter is abandoned, you should avoid using it. Use laminas/laminas-inputfilter instead. Package zendframework/zend-form is abandoned, you should avoid using it. Use laminas/laminas-form instead. Package zendframework/zend-eventmanager is abandoned, you should avoid using it. Use laminas/laminas-eventmanager instead. Package zendframework/zend-code is abandoned, you should avoid using it. Use laminas/laminas-code instead. Package zendframework/zend-console is abandoned, you should avoid using it. Use laminas/laminas-console instead. Package zendframework/zend-mvc is abandoned, you should avoid using it. Use laminas/laminas-mvc instead. Package zendframework/zend-math is abandoned, you should avoid using it. Use laminas/laminas-math instead. Package zendframework/zend-crypt is abandoned, you should avoid using it. Use laminas/laminas-crypt instead. Package zendframework/zend-di is abandoned, you should avoid using it. Use laminas/laminas-di instead. Package zendframework/zend-session is abandoned, you should avoid using it. Use laminas/laminas-session instead. Package zendframework/zend-db is abandoned, you should avoid using it. Use laminas/laminas-db instead. Package zendframework/zend-captcha is abandoned, you should avoid using it. Use laminas/laminas-captcha instead. Package zendframework/zend-barcode is abandoned, you should avoid using it. Use laminas/laminas-barcode instead. Package guzzlehttp/streams is abandoned, you should avoid using it. No replacement was suggested. Package guzzlehttp/ringphp is abandoned, you should avoid using it. No replacement was suggested. Package zendframework/zend-json is abandoned, you should avoid using it. Use laminas/laminas-json instead. Package zendframework/zend-view is abandoned, you should avoid using it. Use laminas/laminas-view instead. Package zendframework/zend-text is abandoned, you should avoid using it. Use laminas/laminas-text instead. Package zendframework/zend-server is abandoned, you should avoid using it. Use laminas/laminas-server instead. Package zendframework/zend-soap is abandoned, you should avoid using it. Use laminas/laminas-soap instead. Package zendframework/zend-serializer is abandoned, you should avoid using it. Use laminas/laminas-serializer instead. Package zendframework/zend-config is abandoned, you should avoid using it. Use laminas/laminas-config instead. Package zendframework/zend-modulemanager is abandoned, you should avoid using it. Use laminas/laminas-modulemanager instead. Package zendframework/zend-log is abandoned, you should avoid using it. Use laminas/laminas-log instead. Package zendframework/zend-i18n is abandoned, you should avoid using it. Use laminas/laminas-i18n instead. Package zendframework/zend-feed is abandoned, you should avoid using it. Use laminas/laminas-feed instead.