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.55k stars 9.32k forks source link

url_rewrite deleted or contain wrong url_key when saving product on storeview #39096

Open mveldhuizen opened 2 months ago

mveldhuizen commented 2 months ago

Preconditions and environment

Magento version: => 2.4.7 Multiple storeviews in 1 website (example default and german) Configuration:

Steps to reproduce

Example 1:

  1. Create a new product (test-product)
  2. Edit product in scope of storeview (example german)
  3. Add product to a category in this scope
  4. save the product

Example 2:

  1. Create a new product (test-product) and add product to a category (in global scope)
  2. Edit product in scope of storeview (example german)
  3. Change url-key of the product in this scope
  4. save the product

Expected result

Example 1:

Product should have rewrite urls for both store views: rewrites_expected

Example 2:

Product should have valid url rewrites for both stores and use the correct url_key for each store: rewrites_expected_2

Actual result

Example 1:

Product does not have a url_rewrite for the other storeview: rewrites_result

Example 2: The url_rewrite without any category link is removed. And the product url within the category of the default storeview now contains the url_key from the german store. rewrites_result_2

Additional information

I think the new system in magento 2.4.7 for saving url rewrites for multiple stores is the issue. This was introduced in: https://github.com/magento/magento2/pull/35053

app/code/Magento/CatalogUrlRewrite/Model/ProductScopeRewriteGenerator.php:219 checks if store is global (which it is not) and then runs generateCategoryUrlsInStoreGroup which has some flaws which result in deleted or broken url_rewrites

There is a workaround when the product has wrong url_rewrites. You can edit the product in admin store and update the categories (add one, save, remove it again). This regenerates the url_rewrites and as it is saved in admin store the url's will be correct. This bug only happens when saving in a specific storeview.

Release note

No response

Triage and priority

m2-assistant[bot] commented 2 months ago

Hi @mveldhuizen. Thank you for your report. To speed up processing of this issue, 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:

m2-assistant[bot] commented 2 months 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:

roman-michak-hh-global commented 2 months ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 2 months ago

Hi @roman-michak-hh-global. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 2 months ago

Hi @roman-michak-hh-global, here is your Magento Instance: https://9726342261dda0c8388f43250298023a.instances-prod.magento-community.engineering Admin access: https://9726342261dda0c8388f43250298023a.instances-prod.magento-community.engineering/admin_3c92 Login: eb915a8d Password: 8f199513b96d

engcom-Bravo commented 2 months ago

Hi @mveldhuizen,

Thanks for your reporting and collaboration.

We have verified the issue in Latest 2.4-develop instance and the issue is reproducible.Kindly refer the screenshots.

Example 1: It seems to be working fine. Product should have rewrite urls for both store views

Screenshot 2024-08-27 at 12 13 36

Example 2: product url within the category of the default storeview now contains the url_key from the german store.

Screenshot 2024-08-27 at 12 20 44

Hence Confirming the issue.

Thanks.

github-jira-sync-bot commented 2 months ago

:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-12843 is successfully created for this GitHub issue.

m2-assistant[bot] commented 2 months ago

:white_check_mark: Confirmed by @engcom-Bravo. Thank you for verifying the issue.
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.

mveldhuizen commented 2 months ago

Hi @engcom-Bravo,

Thanks for confirmation of example 2.

For example 1 you say: "Example 1: It seems to be working fine. Product should have rewrite urls for both store views". The problem with example 1 is not that the category urls are wrong but there is a missing url rewrite for store 1 to the direct product url. So your screenshot does not prove that example 1 is not an issue.

So in your dataset I would expect another 2 rewrites for "test-product.html" (without category) that link to "catalog/product/view/35", but the one for store id 1 is missing.

Thanks.

MaximGns commented 1 month ago

Hi, I can confirm that we also have this issue after upgrading to magento 2.4.7

We have 2 storeviews in the same group.

We save the dutch version of the product on the default store (0), this generates it correctly. Then our importer saved the french product ofcourse on the french storeview and this breaks everything.

Scherm­afbeelding 2024-09-25 om 09 28 08

If you see in the screenshot, the dutch storeview has french category names. Now the funny thing, if I now save the product on the NL storeview the situation of screenshot above is "reversed"

Scherm­afbeelding 2024-09-25 om 09 52 29

Now french urls are containing dutch category names.

Something is crearly really wrong with recent magento version :)