magento2
magento2 copied to clipboard
#32910 fix rewriting category product URL for the one store group
Description (*)
Fixed adding category to product in store view scope to generate all url rewrites
Fixed Issues (if relevant)
- Fixes magento/magento2#32910
Manual testing scenarios (*)
- Create 2 store views
- Create category with anchor enabled (and in 2.4.2 make sure category/product url generation is enabled)
- Add new product without category
- Open product edit in storeview scope
- Add product to category and save
Contribution checklist (*)
- [ ] Pull request has a meaningful description of its purpose
- [ ] All commits are accompanied by meaningful commit messages
- [ ] All new or changed code is covered with unit/integration tests (if applicable)
- [ ] README.md files for modified modules are updated and included in the pull request if any README.md predefined sections require an update
- [ ] All automated tests passed successfully (all builds are green)
Hi @korovitskyi. Thank you for your contribution Here are some useful tips how you can test your changes using Magento test environment. Add the comment under your pull request to deploy test or vanilla Magento instance:
-
@magento give me test instance
- deploy test instance based on PR changes -
@magento give me 2.4-develop instance
- deploy vanilla Magento instance
:exclamation: Automated tests can be triggered manually with an appropriate comment:
-
@magento run all tests
- run or re-run all required tests against the PR changes -
@magento run <test-build(s)>
- run or re-run specific test build(s) For example:@magento run Unit Tests
<test-build(s)>
is a comma-separated list of build names. Allowed build names are:
-
Database Compare
-
Functional Tests CE
-
Functional Tests EE
, -
Functional Tests B2B
-
Integration Tests
-
Magento Health Index
-
Sample Data Tests CE
-
Sample Data Tests EE
-
Sample Data Tests B2B
-
Static Tests
-
Unit Tests
-
WebAPI Tests
-
Semantic Version Checker
You can find more information about the builds here
:information_source: Run only required test builds during development. Run all test builds before sending your pull request for review.
For more details, review the Magento Contributor Guide documentation.
:warning: According to the Magento Contribution requirements, all Pull Requests must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.
:clock10: You can find the schedule on the Magento Community Calendar page.
:telephone_receiver: The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.
:pencil2: Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel
@magento run all tests
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.
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.
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.
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.
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.
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.
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 run all tests
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 run all tests
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 run all tests
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 run Functional Tests B2B,Functional Tests CE,Functional Tests EE,WebAPI Tests
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 run all tests
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 run Functional Tests B2B,Functional Tests CE,Functional Tests EE
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.
Hi @korovitskyi,
Thank you for your contribution!
By looking at your steps, it seems that when assigning a category to product from edit, you have selected the category from other category which is not the Root Category for that store. Can you please confirm on this.
The category product url will gets generated for the selected scope against the category, if, that category is or falls under the category which we select as a Root category in store/scope. So wanted to confirm that, are you selecting the category which does not belongs to the scope. It might be the reason you are not getting the second entry.
I have tried to reproduce this issue on my local by following below steps
- Created New website(germany), new store, and new store view. While creating new Store, I have selected Default Category as my Root category.
-
I have created a new category(Germany).
-
Created new product(test product) Note: Currently I have selected “Main website and Germany” under “Products in Websites” section. and saved it. As we have assigned 2 websites to this product, Here we got 2 entries for each store id
-
Open the product in Edit mode, changed the scope to new scope i.e. Germany store view and selected one category from Default Category(gear). By doing this, the category url entry gets created for the scope for which its gets selected. So here we can see 2 entries for new store id-8, and 1 for default store-1
So as per the above steps the issue is not reproducible for me.
As I have mentioned above, can you please check and reconfirm once on your steps.
Thank you!
As mentioned in above comment the issue is not reproducible for me.
Since the issue is not reproducible and didn't got any reply on other steps to reproduce if any, closing this PR now.
Please reopen and update if you wish to continue.
Thank you for your contribution!
@engcom-Charlie: please try again but use 2 storeviews only and not 2 websites + 2 stores + 2 storeviews.
The expectation is that there will be 2 url rewrites generated because the category is scoped on "global" level, so when you save a category on a product, it should assign the product to the category on global level - which it does (meaning in this specific case the 2 storeviews use the same category) and so it's expected that all storeviews get an url rewrite generated.
But your test case is a good one to test as well after applying the changes from this PR, to make sure if you work with two different websites and two different root categories that only the necessary url rewrites get generated, so test your scenario with this PR applied and see if only the expected url rewrites get generated and not too many of them.
Thanks!
@hostep Thank you for your reply!
I will check the issue as per the above mentioned points.
Hi @hostep,
As per your recent comment, I have tried to reproduce the issue as below.
-
Created only new store view (storeview2) on 2.4 develop, so ultimately we have i. Main Website, Main Website Store, Default Store View ii. Main Website, Main Website Store, storeview2
-
Created new category “test” under Default Category of Magento
-
Created new product "testnew". Here 2 urls got created, 1 for store_id 1 and for store_id 2
-
Edited the product, changed the scope to “[storeview2] and assigned newly created category “test”. By doing this, we can see 2 entries for new store id-2, and 1 for default store-1
-
I have also assigned the other existing category "Gear" to this newly created product. Here also we can see new 2 entries for new store id-2, and 1 for default store-1
So as per the above steps the issue is still not reproducible for me.
Can you please let me know if I am missing anything in order to reproduce this issue.
Thank you in advance!
@engcom-Charlie: thanks for re-testing.
And actually you succeeded in reproducing the bug. You are missing the following 2 records in your url_rewrite
table:
-
gear/testnew.html
for store_id 1 -
test/testnew.html
for store_id 1
They only got generated for store_id 2, but are missing for store_id 1, that's what the bug report in #32910 is about 🙂
Hi @hostep,
Thank you for this clarity.
Will check the PR changes accordingly now and look into the test failures.
Thank you!
@magento run all tests
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.