-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Do not trigger url rewrites re-generation for all store views #32808
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
Do not trigger url rewrites re-generation for all store views #32808
Conversation
Hi @ihor-sviziev. Thank you for your contribution
❗ Automated tests can be triggered manually with an appropriate comment:
You can find more information about the builds here ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review. For more details, please, review the Magento Contributor Guide documentation. 🕙 You can find the schedule on the Magento Community Calendar page. 📞 The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket. 🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel ✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel |
@magento run all tests |
@magento run Functional Tests EE, WebAPI Tests |
Hi @ihor-sviziev, thanks for contributing! Can you provide more details on the impact of this fix? Thanks! |
@magento run all tests |
Hi @gabrieldagama, |
@magento run Functional Tests B2B |
No builds to run for your request. |
@magento run Functional Tests B2B |
No builds to run for your request. |
@magento run Functional Tests B2B |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
@magento create issue |
@ihor-sviziev Thanks for collaboration and detailed description. |
@Den4ik, in theory, we might change it, but I don't know why it was done in this way and wonder if it would cause some regression. Also, potentially, there might be similar code in some other piece or custom extension with the same behavior. My current changes fix all cases at once, so should cover all cases |
@ihor-sviziev May be we could little bit research and if it's possible reduce count of save calls that will have a positive effect on performance? |
@Den4ik, in general, it's a good idea to do such research and get rid of such pieces. But in the case of fixing this issue - that's not relevant - I won't break any functionality. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️ Approve. All looks good for me.
As we discussed in Slack research should be done as separate work.
Hi @Den4ik, thank you for the review.
|
Hi @ihor-sviziev , @Den4ik ❌ QA not Passed URL Re-Write regenerates for all the store views Execution steps followed as below
✔️ Expected result After Fix
❌ Actual result After Fix
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on the above comment, moving it back to to Request Changes
Hi @ihor-sviziev, Thank you for your contribution! I am trying to understand and reproduce this issue on my local. Followed below steps but I am getting the same results on 2.4 develop and PR branch.
On both the branches ie. on 2.4 develop and on this PR branch, url_rewrite_ids of few records are getting changed after step 9 on, so can you please confirm once and give us some more information on this. Thank you in advance! |
Please ping me in slack for further details
…On Mon, 11 Oct 2021 at 17:55 Indrani ***@***.***> wrote:
Hi @ihor-sviziev <https://github.com/ihor-sviziev>,
Thank you for your contribution!
I am trying to understand and reproduce this issue on my local. Followed
below steps but I am getting the same results on 2.4 develop and PR branch.
1. Setup fresh magento instance
2. Added 2 new sub categories under Default Category. Created 2
products under one sub category and 1 in other. Eg.(Electronics and Cloths
are sub categories and lamp, geyser are products under Electronics and
t-shirt product is under cloths)
3. Checked url_rewrite table: total 12 records were present.
4. Execute php bin/magento app:config:dump scopes command
5. Took Db dump at this stage
6. Added one website, store and view against default category
7. Checked the url_rewrite table again. Now total 18 records were
present
8. Executed php bin/magento app:config:dump scopes again
9. Applied the DB dump back to Magento instance from the step 5.
10. Executed php bin/magento setup:upgrade, At this, it asked about
“do you want to continue with creating the website” of step 7 , I have
opted for Yes option
11. Tried to browse the site again, its accessible and checked
url_rewrite table again. Its having 18 records
12. Executed php bin/magento app:config:import cmd : Got nothing to
import message here
On both the branches ie. on 2.4 develop and on this PR branch,
url_rewrite_ids of few records are getting changed after step 9 on, so can
you please confirm once and give us some more information on this.
Thank you in advance!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#32808 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAOJOUMHRSG6W4O6ADQPDPLUGL3H5ANCNFSM43KV2QRQ>
.
|
Hi @ihor-sviziev, Thanks for the information over slack. @engcom-Alfa, I have tried to reproduce the issue on 2.4 develop with below steps. Some URL rewrites for categories on stores were re-generated in DB and hence issue is reproducible.
After doing php bin/magento setup:upgrade, the URL rewrites for categories should not be re-generated in this scenario. As the issue exists on mainline so moving this PR further. Thank you! |
Hi @ihor-sviziev and @engcom-Charlie , Thanks for collaboration and coming back with proper steps to reproduce it! I am able to work on it now! |
✔️ QA Passed Manual testing scenario:
Before: ✖️ New url_rewrite_ids were getting generated to old records After: ✔️ New url_rewrite_ids are not getting generated to old records, they are retained as it is! It is a specific case were the DB dump is involved when we are having multi store views, and has no impact on other features, and hence no additional regression is required on this. |
Hi @ihor-sviziev, thank you for your contribution! |
Description (*)
During creating a new website, Store Group and Store view using
php bin/magento setup:upgrade
- we noticed that some URL rewrites for categories on different stores were re-generated in DB, that's absolutely not obvious and for sure not expected behavior. Such behavior, especially for us changed URLs for some categories w/o creating any redirect from old -> new URL (for some reason, we had incorrect url_path values in DB, that's another story).As a result of this issue - some advertised categories started returning 404 pages, and we basically started burning our money.
Root cause analyze
Investigation showed, that
app/code/Magento/CatalogUrlRewrite/Model/Category/Plugin/Store/Group.php
plugin was executed due to 2 step saving of group:magento2/app/code/Magento/Store/Model/Config/Importer/Processor/Create.php
Lines 165 to 195 in 6729b6e
As a store group still don't have any store IDs assigned (the store will be created on the next step) -
$group->getStoreIds()
returns an empty array, we're setting this value to the category and trying to generate URL rewritesmagento2/app/code/Magento/CatalogUrlRewrite/Model/Category/Plugin/Store/Group.php
Lines 155 to 157 in a2b9380
Then it goes to this method, which tries to fetch a list of store Ids:
magento2/app/code/Magento/CatalogUrlRewrite/Model/CategoryUrlRewriteGenerator.php
Lines 116 to 143 in c051134
Here we don't have any saved
store_ids
, so it fetches the list of stores where this category used as a root.magento2/app/code/Magento/Catalog/Model/Category.php
Lines 534 to 570 in 68c7282
As a result - we're re-generating category URL rewrites for all store views with the same root category ID.
Related Pull Requests
Fixed Issues (if relevant)
Manual testing scenarios (*)
php bin/magento app:config:dump scopes
to dump all the stores data into the config.phpphp bin/magento app:config:dump scopes
to dump all the stores data into the config.php, save the filephp bin/magento setup:upgrade
orphp bin/magento app:config:import
to create a new website, store group, store viewurl_rewrites
table with a backup file for the store 1.Expected result:
✔ URL rewrites for store 1 shouldn't be touched when we creating a new website / store group / store view
Actual result:
❌ URL rewrites for store 1 are re-generated when we creating a new website / store group / store view
Questions or comments
Contribution checklist (*)
Resolved issues: