Skip to content

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

Open
@mveldhuizen

Description

@mveldhuizen

Preconditions and environment

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

  • catalog/seo/product_use_categories = yes
  • catalog/seo/generate_category_product_rewrites = yes

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: #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

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: CatalogComponent: DBIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P2A defect with this priority could have functionality issues which are not to expectations.Progress: ready for devReported on 2.4.7Indicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branch

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions