magento2 icon indicating copy to clipboard operation
magento2 copied to clipboard

#32910 fix rewriting category product URL for the one store group

Open korovitskyi opened this issue 3 years ago • 91 comments

Description (*)

Fixed adding category to product in store view scope to generate all url rewrites

Fixed Issues (if relevant)

  1. Fixes magento/magento2#32910

Manual testing scenarios (*)

  1. Create 2 store views
  2. Create category with anchor enabled (and in 2.4.2 make sure category/product url generation is enabled)
  3. Add new product without category
  4. Open product edit in storeview scope
  5. 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)

korovitskyi avatar Feb 02 '22 16:02 korovitskyi

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:

  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE,
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. 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

m2-assistant[bot] avatar Feb 02 '22 16:02 m2-assistant[bot]

@magento run all tests

korovitskyi avatar Feb 02 '22 16:02 korovitskyi

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

korovitskyi avatar Feb 21 '22 09:02 korovitskyi

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

engcom-Lima avatar Mar 07 '22 13:03 engcom-Lima

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

engcom-Lima avatar Mar 14 '22 20:03 engcom-Lima

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

engcom-Lima avatar Mar 15 '22 08:03 engcom-Lima

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

engcom-Charlie avatar Mar 23 '22 09:03 engcom-Charlie

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

engcom-Charlie avatar Mar 23 '22 14:03 engcom-Charlie

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

  1. Created New website(germany), new store, and new store view. While creating new Store, I have selected Default Category as my Root category.

image

  1. I have created a new category(Germany).

  2. 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 image

  3. 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 image

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!

engcom-Charlie avatar Mar 24 '22 14:03 engcom-Charlie

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 avatar Apr 14 '22 09:04 engcom-Charlie

@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 avatar Apr 20 '22 13:04 hostep

@hostep Thank you for your reply!

I will check the issue as per the above mentioned points.

engcom-Charlie avatar Apr 25 '22 06:04 engcom-Charlie

Hi @hostep,

As per your recent comment, I have tried to reproduce the issue as below.

  1. 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 image

  2. Created new category “test” under Default Category of Magento image

  3. Created new product "testnew". Here 2 urls got created, 1 for store_id 1 and for store_id 2

  4. 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

  5. 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 image

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 avatar Apr 25 '22 13:04 engcom-Charlie

@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 🙂

hostep avatar Apr 25 '22 14:04 hostep

Hi @hostep,

Thank you for this clarity.

Will check the PR changes accordingly now and look into the test failures.

Thank you!

engcom-Charlie avatar Apr 26 '22 06:04 engcom-Charlie

@magento run all tests

engcom-Charlie avatar Apr 26 '22 06:04 engcom-Charlie

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.