-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent side effect on category objects store_id and url_key on save #28164
Prevent side effect on category objects store_id and url_key on save #28164
Conversation
Hi @schmengler. Thank you for your contribution
For more details, please, review the Magento Contributor Guide documentation. |
(I'm wating if the PR breaks the core test suite because of all the mocking before committing my own test) |
5b2402a
to
31c5963
Compare
@magento create issue |
@magento run all tests |
Hi @ihor-sviziev, thank you for the review. |
@magento run all tests |
Hi @schmengler, thank you for your contribution! |
Description (*)
Category URL rewrites are saved by an "after save" observer for categories. But if saved for global scope, the URL rewrite generator itself modifies the passed category object for each assigned store to generate URL rewrites for all stores. Afterwards, url_key, url_path and store_id have the values of the last processed store id. This has side effects on later observers or other code that works on the category object after saving it.
Since the default store (0) is always the first item of
$category->getStoreIds()
I chose to clone the category object only for the other stores, so that url_key and url_path for the global scope are still set to the original object.Related Pull Requests
Fixed Issues (if relevant)
Manual testing scenarios (*)
Abbreviated test case
Questions or comments
Contribution checklist (*)
Resolved issues: