Description
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:
- Create a new product (test-product)
- Edit product in scope of storeview (example german)
- Add product to a category in this scope
- save the product
Example 2:
- Create a new product (test-product) and add product to a category (in global scope)
- Edit product in scope of storeview (example german)
- Change url-key of the product in this scope
- save the product
Expected result
Example 1:
Product should have rewrite urls for both store views:
Example 2:
Product should have valid url rewrites for both stores and use the correct url_key for each store:
Actual result
Example 1:
Product does not have a url_rewrite for the other storeview:
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.
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”.