Magento2: getUrlPath() not working correct with store views with url-fallback

Created on 9 Jul 2019  路  16Comments  路  Source: magento/magento2

Preconditions (*)

  1. Magento 2.3.x
  2. PHP 7.2.119

Steps to reproduce (*)

  1. Create some store views for different countries - f.e. de, de_at, de_ch, en and en_gb
  2. Add categories and use for de, de_at and de_ch same url (all 3 store views are in german - so name of category is same) by using checkbox "Use Default Value" vor field "url_key".
  3. Translate category for english store views "en" and "en_gb". Use also checkbox "Use Default Value" vor field "url_key".
  4. Add function to shop $this->categoryRepository->get($this->registry->registry('current_category')->getId(), $value['store_id'])->getUrlPath() (f. e. to generate hreflang-tag)

Expected result (*)

  1. URL in hreflang-tag should look like:
    https://www.domain.com/de/kategorie-german.html
    https://www.domain.com/de_at/kategorie-german.html
    https://www.domain.com/de_ch/kategorie-german.html
    https://www.domain.com/en/category-english.html
    https://www.domain.com/en_gb/category-english.html

Actual result (*)

  1. But URL in hreflang-tag look like:
    https://www.domain.com/de/kategorie-german.html
    https://www.domain.com/de_at/category-english.html
    https://www.domain.com/de_ch/category-english.html
    https://www.domain.com/en/category-english.html
    https://www.domain.com/en_gb/category-english.html

The problem is, that there is no entry in table catalog_category_entity_varchar for store views using "Use Default Value" vor field "url_key".

MysqlMq Cannot Reproduce Confirmed P2 done Reproduced on 2.3.x S2 Dev.Experience

Most helpful comment

Issue: Confirmed

All 16 comments

Hi @matin73. 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 give me 2.3-develop instance - upcoming 2.3.x release

For more details, please, review the Magento Contributor Assistant documentation.

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

  • [ ] yes
  • [ ] no

Hi @matin73. 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 give me 2.3-develop instance - upcoming 2.3.x release

For more details, please, review the Magento Contributor Assistant documentation.

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

* x  yes

* [ ]  no


* Join [Magento Community Engineering Slack](http://tinyurl.com/engcom-slack) and ask your questions in [#github](https://magentocommeng.slack.com/messages/C7KB93M32) channel.

Hi @matin73. Thank you for your request. I'm working on Magento 2.3-develop instance for you

Hi @matin73, here is your Magento instance.
Admin access: https://i-23640-2-3-develop.instances.magento-community.engineering/admin
Login: admin Password: 123123q
Instance will be terminated in up to 3 hours.

Hi @matin73, here is your Magento instance.
Admin access: https://i-23640-2-3-develop.instances.magento-community.engineering/admin
Login: admin Password: 123123q
Instance will be terminated in up to 3 hours.

Thanks. But I can not add function $this->categoryRepository->get($this->registry->registry('current_category')->getId(), $value['store_id'])->getUrlPath() (f. e. to generate hreflang-tag) which shows problem

Hi @engcom-Bravo. 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: :point_down:

  • [ ] 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 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 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.

Issue: Confirmed

Hello,@matin73 ! I can't reproduce this issue on fresh 2.3-develop. Can you give me more steps to reproduce or update your added steps with more details?
Thanks!

@engcom-Bravo did you make some module with this function?

@matin73 i edit this:
tesss

please try with some custom module

and please try with store views id like this:
de = ID 1
en = ID 2
de_at = ID 3
de_ch = ID 4
en_gb = ID 5

Because there is some strange fallback.
ID 1 de = correct url,
ID 2 en = correct url,
ID 3 de_at and ID 4 de_ch = wrong url -> shows url of en ID 2 en. but this is wrong, because ID 3 de_at and ID 4 de_ch should show url of ID 1 de.

please also have a look into table catalog_category_entity_varchar. There are no entries for store views de_at = ID 3, de_ch = ID 4, en_gb = ID 5 (store views using "Use Default Value" vor field "url_key"). In Magento 1 there where also entries genereated for other store views. We have importet with migration tool and first it worked correct, because migration tool also migrated all store view urls. after saving any of these categories the entries in catalog_category_entity_varchar get deleted and the function has wrong fallback

@matin73 , thank for contributing! That is right.

:white_check_mark: Confirmed by @engcom-Bravo
Thank you for verifying the issue. Based on the provided information internal tickets MC-18325 were created

Issue Available: @engcom-Bravo, _You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself._

The related internal Jira ticket MC-23858 was closed as non-reproducible in 2.4-develop.
It means that Magento team either unable to reproduce this issue using provided _Steps to Reproduce_ from the _Description section_ on clean Magento instance or the issue has been already fixed in the scope of other tasks.

But if you still run into this problem on the latest 2.4-develop please create new Issue with updated information/steps/preconditions in the _Description section_.

Was this page helpful?
0 / 5 - 0 ratings