Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REST-API locale is always default scope #19908

Closed
jwundrak opened this issue Dec 20, 2018 · 11 comments
Closed

REST-API locale is always default scope #19908

jwundrak opened this issue Dec 20, 2018 · 11 comments
Assignees
Labels
Component: Webapi Use with concrete module component label E.g. "Component: Webapi" + "Catalog" Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release

Comments

@jwundrak
Copy link
Contributor

jwundrak commented Dec 20, 2018

Preconditions (*)

  1. Error occourds in 2.1.14, but I can reproduce this also in 2.3-develop
  2. at least two store views. Default store-view locale != second store view
  3. It doesn't matter, if you have one or multiple stores

Steps to reproduce (*)

  1. Configure stores. I use Store-View "default" with locale en_US and StoreView "second" with locale de_DE
  2. Use something, that returns magento phrase (I wrote a test module here: https://github.com/jwundrak/magento2-api-locale )
  3. Call rest API (with the module /rest/second/V1/localeTest)

Actual result (*)

Output of the test module:

{
    "locale": "en_US",
    "test_translation": "Category",
    "store_code": "second",
    "store_locale": "de_DE"
}

Expected result (*)

Output of the test module:

{
    "locale": "de_DE",
    "test_translation": "Kategorie",
    "store_code": "second",
    "store_locale": "de_DE"
}

Possible solution

In \Magento\Webapi\Controller\PathProcessor::process I start an emulation of the locale: $this->localeResolver->emulate($this->storeManager->getStore()->getId()); . I'm not sure, if this is the correct way, but works here in 2.1 and 2.3: https://gist.github.com/jwundrak/11ea7ca0b5c6cea57d3b7c8133548634

@magento-engcom-team
Copy link
Contributor

Hi @jwundrak. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento-engcom-team give me $VERSION instance

where $VERSION is version tags (starting from 2.2.0+) or develop branches (for example: 2.3-develop).
For more details, please, review the Magento Contributor Assistant documentation.

@jwundrak do you confirm that you was able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • yes
  • no

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Dec 20, 2018
@jwundrak
Copy link
Contributor Author

do you confirm that you was able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • yes
  • no

@shikhamis11 shikhamis11 self-assigned this Dec 20, 2018
@magento-engcom-team
Copy link
Contributor

magento-engcom-team commented Dec 20, 2018

Hi @shikhamis11. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento-engcom-team give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento-engcom-team give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

  • 6. Add label Issue: Confirmed once verification is complete.

  • 7. Make sure that automatic system confirms that report has been added to the backlog.

@shikhamis11
Copy link
Member

@jwundrak I tried the same at magento 2.2 and 2.3 got the 2nd store locale

@shikhamis11 shikhamis11 added Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Component: Backend Component: Webapi Use with concrete module component label E.g. "Component: Webapi" + "Catalog" Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed and removed Component: Backend labels Dec 20, 2018
@magento-engcom-team
Copy link
Contributor

@shikhamis11 Thank you for verifying the issue. Based on the provided information internal tickets MAGETWO-97267, MAGETWO-97268 were created

@magento-engcom-team magento-engcom-team added the Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development label Dec 20, 2018
@jwundrak
Copy link
Contributor Author

@shikhamis11 the expected and actual result was mixed up. I edit the description

@shikhamis11
Copy link
Member

@jwundrak yes you are right I tried with ar_SA and en_US (default) got the result
{
"locale": "en_US",
"test_translation": "Category",
"store_code": "admin",
"store_locale": "ar_SA"
}

@jwundrak
Copy link
Contributor Author

@shikhamis11 what's with the patch in the gist. This resolves the error, but I don't know, if this way is good.
If so, I can prepare a pull request and write some tests

@shikhamis11
Copy link
Member

shikhamis11 commented Dec 20, 2018

@jwundrak I am not completely sure about the patch but if it fix the issue go for pull request

@shikhamis11 shikhamis11 removed their assignment Dec 20, 2018
jwundrak added a commit to jwundrak/magento2 that referenced this issue Dec 20, 2018
jwundrak added a commit to jwundrak/magento2 that referenced this issue Dec 22, 2018
jwundrak added a commit to jwundrak/magento2 that referenced this issue Dec 27, 2018
@alexander-aleman
Copy link
Contributor

I created a plugin using your fix as a workaround https://packagist.org/packages/xsarus/magento2-rest-api-locale

@ghost ghost assigned jwundrak Mar 28, 2019
@magento-engcom-team
Copy link
Contributor

Hi @jwundrak. Thank you for your report.
The issue has been fixed in #19913 by @jwundrak in 2.3-develop branch
Related commit(s):

The fix will be available with the upcoming 2.3.2 release.

@magento-engcom-team magento-engcom-team added the Fixed in 2.3.x The issue has been fixed in 2.3 release line label Apr 29, 2019
magento-engcom-team added a commit that referenced this issue Apr 29, 2019
…19913

 - Merge Pull Request #19913 from jwundrak/magento2:issue/19908-rest-api-locale
 - Merged commits:
   1. 5abd330
   2. ef724a6
   3. 29b4b39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Webapi Use with concrete module component label E.g. "Component: Webapi" + "Catalog" Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release
Projects
None yet
Development

No branches or pull requests

4 participants