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.49k stars 9.29k forks source link

Product save does not update URL rewrites for all store views in Magento 2.4.5-p1 if URL Key is preset on store view scope different from the saved one #36733

Closed kanevbg closed 1 year ago

kanevbg commented 1 year ago

Preconditions and environment

Steps to reproduce

  1. Use Magento 2.4.5-p1 with the official DEMO data
  2. Navigate to admin panel
  3. Open product with ID=2024
  4. Add the product to the "DE" website. Check url_rewrite, with proper knowledge on place you will understand that they are correct.
  5. Switch the scope to "DE View", set the URL Key "url-key-in-de-store-view", unset the "Create Permanent Redirect for old URL" checkbox (in order to keep the data simpler) and save the product. Again you should understand that the data for that product in url_rewrites table is correct at this time.
  6. Now switch back to Global scope for the product, remove the product's categories leaving only the "Default Category" and save the product. Now the url_rewrites table will hold the following data: image If you know the algorithms you will understand that the rows marked with X on the image above should not be existing too as the product at that time is not in these categories anymore. If the categories were removed from the "DE View" store view you would not observe the issue as it will not happen.

Expected result

Only two records to exists in the url_rewrite table for "entity_type = "product" and entity_id = 2024" as the product in not in ANY categories, only the root category, so one URL without category should exists per each store view the product is added in.

Actual result

The url_rewrite table hold obsolete URLs which were used for categories the product was previously added in for the store "DE View".

Additional information

No response

Release note

Fixes issue where product save does not update URL rewrites for all store views in Magento 2.4.5 if URL Key is preset on store view scope different from the saved one from the admin panel.

Triage and priority

m2-assistant[bot] commented 1 year ago

Hi @kanevbg. Thank you for your report. To speed up processing of this issue, make sure that you provided the following information:

Make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, review the Magento Contributor Assistant documentation.

Add a comment to assign the issue: @magento I am working on this

To learn more about issue processing workflow, refer to the Code Contributions.


:clock10: You can find the schedule on the Magento Community Calendar page.

:telephone_receiver: The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

:pencil2: Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

m2-assistant[bot] commented 1 year ago

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:

engcom-Bravo commented 1 year ago

Hi @kanevbg,

Thank you for reporting and collaboration. Verified the issue on Magento 2.4-develop instance and the issue is not reproducible. Kindly refer the screenhsots.

Steps to reproduce :

1.Navigate to admin panel 2.Open product with ID=2092 3.Add the product to the "DE" website. Check url_rewrite, with proper knowledge on place you will understand that they are correct. 4.Switch the scope to "DE View", set the URL Key "url-key-in-de-store-view", unset the "Create Permanent Redirect for old 5.URL" checkbox (in order to keep the data simpler) and save the product. Again you should understand that the data for that product in url_rewrites table is correct at this time. 6.Now switch back to Global scope for the product, remove the product's categories leaving only the "Default Category" and save the product. Now the url_rewrites table will hold the following data:

Screenshot 2023-01-12 at 2 12 10 PM Screenshot 2023-01-12 at 2 11 53 PM

We are getting only two records in url_rewrite table.

Kindly recheck the behavior on Magento 2.4-develop instance and elaborate steps to reproduce if the issue is still reproducible.

Thanks.

kanevbg commented 1 year ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 1 year ago

Hi @kanevbg. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 1 year ago

Hi @kanevbg, here is your Magento Instance: https://0c6b862f4ff2b8d1ffcfcb95a258560e.instances.magento-community.engineering Admin access: https://0c6b862f4ff2b8d1ffcfcb95a258560e.instances.magento-community.engineering/admin_5d29 Login: e3856386 Password: 1cd9772220eb

kanevbg commented 1 year ago

@engcom-Bravo the Magento Instance provided by the bot is not having second website, I'd have to check that later on local instance.

engcom-Bravo commented 1 year ago

Thanks for quick response @kanevbg

kanevbg commented 1 year ago

I compared 2.4.5-p1 sources to the 2.4-develop source and identified change in the Magento_CatalogUrlRewrite module which pointed me to that commit: https://github.com/magento/magento2/commit/e46f719559924e703ef3c7fdc728ec1b232a7509 (ACP2E-1304)

This is what resolved the issue, so yes, it is fixed in 2.4-develop already.

EDIT: There is still problematic case. When saving product from store view scope and you have added the product to more categories for that save, then if the product were added to other website where the product has url_key for the concrete store view(s) than for these store views the links will not be created! So basically the same problem, but in order to observe it you should save the product from store view scope and have the product at least to 1 other store view with custom url_key for that scope. @engcom-Bravo I guess you can reproduce it with that info, if you are unable to, please let me know.

hostep commented 1 year ago

@kanevbg: your new problematic case sounds related to what is trying to be fixed here: https://github.com/magento/magento2/pull/35053, not sure if it's exactly the same though.

kanevbg commented 1 year ago

@hostep By description and code change it seems to target the same problematic case. Thank you for sharing and I am adding the issue link: https://github.com/magento/magento2/issues/32910. As far as I understand the PR is logically accepted and this will likely be the code changes to be merged so I will try the changes from the PR as patch in one of my projects and provide feedback later on.

engcom-Bravo commented 1 year ago

@hostep Thanks for your contribution & collaboration over here.

Hi @kanevbg,

Thanks for your update.

Kindly can you update can we close this as duplicate of https://github.com/magento/magento2/issues/32910.

Thanks.

kanevbg commented 1 year ago

@engcom-Bravo @hostep sadly the changes of #35053 do not resolved the case described in that issue :/ Maybe the internal person who worked out that fix https://github.com/magento/magento2/commit/e46f719559924e703ef3c7fdc728ec1b232a7509 should be notified for that issue maybe he/she is in best position to fix it for the case where the save and category changes is performed from the store view scope.

kanevbg commented 1 year ago

@engcom-Bravo Please re-test with the case described in the edit of that comment: https://github.com/magento/magento2/issues/36733#issuecomment-1380491110 in order to decide if the issue needs updating or is ready for work.

engcom-Bravo commented 1 year ago

Hi @kanevbg,

Thanks for your update.

Kindly can you elaborate the steps for this comment https://github.com/magento/magento2/issues/36733#issuecomment-1380491110 for reproduce the issue. it will helpful for us.

Thanks.

kanevbg commented 1 year ago

@engcom-Bravo Sure, sorry for being late.

Steps to reproduce

  1. Use Magento 2.4.5-p1 with the official DEMO data, but create one or more websites and their sub-entities (store group and store view). EG: create website for "FR" and "BG"
  2. Navigate to admin panel
  3. Open product with ID=2024
  4. Add the product to all of the rest websites (at least 3 in total). Check url_rewrite, with proper knowledge on place you will understand that they are correct for each store view.
  5. Switch the scope to "DE View", set the URL Key "url-key-in-de-store-view", unset the "Create Permanent Redirect for old URL" checkbox (in order to keep the data simpler) and save the product. Again you should understand that the data for that product in url_rewrites table is correct at this time.
  6. Repeat step 4 for the rest of store view scopes. The exact value of the URL Key is not important, it is important to have a value on store view scope and not "Use default/Use website". Again you should understand that the data for that product in url_rewrites table is correct at this time.
  7. Now switch back to DE store view scope for the product, remove the product's categories leaving only the "Default Category" and save the product. Now the url_rewrites table will still hold data for the rest of the store views with the removed categories of the product even though that the categories are per global scope and they were removed from the product.

Expected result

url_rewrite table for "entity_type = "product" and entity_id = 2024" to hold only URLs without categories.

Actual result

The url_rewrite table holds obsolete URLs which were used for prouduct's URLs with categories the product was previously added in for the store views different from the saved one - "DE View" in the example above.

kanevbg commented 1 year ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 1 year ago

Hi @kanevbg. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 1 year ago

Hi @kanevbg, here is your Magento Instance: https://0c6b862f4ff2b8d1ffcfcb95a258560e.instances.magento-community.engineering Admin access: https://0c6b862f4ff2b8d1ffcfcb95a258560e.instances.magento-community.engineering/admin_c58a Login: aa1159ca Password: 4175a1d27564

kanevbg commented 1 year ago

@engcom-Bravo let me know if you need anything else.

kanevbg commented 1 year ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 1 year ago

Hi @kanevbg. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 1 year ago

Hi @kanevbg, here is your Magento Instance: https://0c6b862f4ff2b8d1ffcfcb95a258560e.instances.magento-community.engineering Admin access: https://0c6b862f4ff2b8d1ffcfcb95a258560e.instances.magento-community.engineering/admin_e435 Login: 50d093be Password: 2f74570215b3

engcom-Bravo commented 1 year ago

Hi @kanevbg,

Thanks for your update.

Verified the issue on Magento 2.4-develop instance and the issue is not reproducible. Kindly refer the screenhsots.

Steps to reproduce :

1.Navigate to admin panel 2.Open product with ID=2024 3.Add the product to all of the rest websites (at least 3 in total). Check url_rewrite, with proper knowledge on place you will understand that they are correct for each store view. 4.Switch the scope to "DE View", set the URL Key "url-key-in-de-store-view", unset the "Create Permanent Redirect for old URL" checkbox (in order to keep the data simpler) and save the product. Again you should understand that the data for that product in url_rewrites table is correct at this time. 5.Repeat step 4 for the rest of store view scopes. The exact value of the URL Key is not important, it is important to have a value on store view scope and not "Use default/Use website". Again you should understand that the data for that product in url_rewrites table is correct at this time. 6.Now switch back to DE store view scope for the product, remove the product's categories leaving only the "Default Category" and save the product. Now the url_rewrites table will still hold data for the rest of the store views with the removed categories of the product even though that the categories are per global scope and they were removed from the product.

Screenshot 2023-01-27 at 2 44 56 PM Screenshot 2023-01-27 at 4 29 11 PM Screenshot 2023-01-27 at 2 44 48 PM

KIndly let us know if we are missing anything.

Kindly recheck the behavior on Magento 2.4-develop instance and elaborate steps to reproduce if the issue is still reproducible.

Thanks.

engcom-Bravo commented 1 year ago

Hi @kanevbg,

We have noticed that this issue has not been updated for a period of 14 Days.
Hence we assume that this issue is fixed now, so we are closing it. Please raise a fresh ticket or reopen this ticket if you need more assistance on this.

Thanks.