Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When the category is saved in Magento backend and particularly when the scope is a custom store, some use cases leave some url key or url path with data that break features like the canonical url in the category page on the frontend.
Description (*)
The changes are twofold:
Related Pull Requests
Fixed Issues (if relevant)
Manual testing scenarios (*)
use case 1: the category url key is set for the global scope and a different value is set for the store scope 2
use case 2: starting with a parent category like the above (with 2 scope set), the child category url key is set for the global scope and the category url key is not set for either of the default store or custom store: only store 0 has a url key
global scope: store id = 0, url path: cat1/cat12
use case 3: the child category uses a url key for the global scope (store 0) and uses a custom url key (cat12_2) for the custom store (store 2)
use case 4: the child category uses a url key for the default store scope (store = 1) (cat12_1) and uses no custom url key for the custom store (store 2)
use case 5: the child category uses a custom url key (cat12_1) for the global scope and uses a custom url key (cat12_2) for the custom store (store 2)
Questions or comments
The PR changes resolve the issue with canonical url being invalid. However, if the parent category url is changed afterwards, it does break the category path. I have attempted to add integration tests but this attempt was shortlived once I realised the category save process cannot be triggered by a single method but rather by using a list of events/plugins and resources. If we wanted this area of the system bug free, we'd need this area (category backend save controller) to be refactored
The changes duplicate existing snippets to try to keep the other logic to work like before as much as possible.
Contribution checklist (*)