magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.56k stars 9.32k forks source link

[Import][Category] Url rewrite for new category doesn't generate correctly #36936

Closed thienhoangtran closed 1 year ago

thienhoangtran commented 1 year ago

Preconditions and environment

Steps to reproduce:

  1. Go to Stores >> Configuration >> General >> Search Engine Optimization >> Set "Yes" in Use Web Server Rewrites.
  2. Go to System >> Data transfer >>Import ->Import a file of products and add new category in the Category column of the file (make sure that category should not be created in the backend).
  3. Now, verify the url rewrite generated for the storeview of the category in Marketing >> Seo & Search >> Url Rewrite.

Expected result

The category URL rewrite is generated for all store view

Actual result

The category URL rewrite is generated for only the default store view of the store group.

Additional information

I found some processes after category saves to handle the URL rewrite here:

\Magento\CatalogUrlRewrite\Observer\CategoryProcessUrlRewriteSavingObserver::execute

In this case, the $category object doesn't have "store_id" data, so it is called a function setCategoryStoreId (line 109).

This is the note of this function In case store_id is not set for category then we can assume that it was passed through product import. Store group must have only one root category, so receiving category's path and checking if one of it parts is the root category for store group, we can set default_store_id value from it to category. it prevents urls duplication for different stores (“Default Category/category/sub” and “Default Category2/category/sub”)

Release note

No response

Triage and priority

m2-assistant[bot] commented 1 year ago

Hi @thienhoangtran. Thank you for your report. To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

m2-assistant[bot] commented 1 year ago

Hi @engcom-Bravo. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

m2-assistant[bot] commented 1 year ago

Hi @engcom-Lima. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

engcom-Lima commented 1 year ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 1 year ago

Hi @engcom-Lima. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 1 year ago

Hi @engcom-Lima, here is your Magento Instance: https://b750f98e3146adca9f0335e632d77431.instances.magento-community.engineering Admin access: https://b750f98e3146adca9f0335e632d77431.instances.magento-community.engineering/admin_3fbd Login: 6a3a656a Password: adaf42b5071a

engcom-Lima commented 1 year ago

Hi @thienhoangtran ,

Thanks for your contribution and collaboration.

I have tried to reproduce the issue but issue is not reproducible to me in 2.4-develop. Followed below steps:

Steps to reproduce:

  1. Run the imported product, and include a new category in the import file.
  2. After import success, check the url_rewrite data for the new category.

Kindly elaborate more steps to reproduce and also please provide us video (if possible). Kindly check this in 2.4-develop instance. Let us know if you are missing anything.

Thanks

thienhoangtran commented 1 year ago

Hi @engcom-Lima

Did you create a second store view for your website / store group?

If you have more than one store view, Magento only generates url_rewrite for the default store view, all good if you have only one store view.

Regards,

engcom-Lima commented 1 year ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 1 year ago

Hi @engcom-Lima. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 1 year ago

Hi @engcom-Lima, here is your Magento Instance: https://b750f98e3146adca9f0335e632d77431.instances.magento-community.engineering Admin access: https://b750f98e3146adca9f0335e632d77431.instances.magento-community.engineering/admin_8b4b Login: 8ab05b0a Password: 3379ea26f6f6

engcom-Lima commented 1 year ago

Hi @thienhoangtran ,

Thanks for your contribution and collaboration.

I have tried to reproduce the issue in latest 2.4-develop instance. But issue is not reproducible to me.

Below is the screenshot for your reference:

Screenshot 2023-03-02 at 4 20 44 PM

CSV file used: catalog_product.csv

Kindly provide us more information about the steps to reproduce. Also, please test it in latest 2.4-develop instance and let us know if you are facing any issue.

Thanks

thienhoangtran commented 1 year ago

Hi @engcom-Lima

I think we're misunderstanding here. We're discussing about url rewrite of Category, not product like your image?

In this case, can you help to show the url_rewrite of category Test1?

Regards,

engcom-Lima commented 1 year ago

Hi @thienhoangtran ,

Thanks for your contribution and collaboration.

Please find the attached screenshot for your reference:

Screenshot 2023-03-03 at 10 47 27 AM

Kindly provide us more information about the steps to reproduce. Also, please test it in latest 2.4-develop instance and let us know if you are facing any issue.

Thanks

thienhoangtran commented 1 year ago

Hi @engcom-Lima

This category is generated during the import process or did you create it manually inside the Backend?

Regards,

engcom-Lima commented 1 year ago

Hi @thienhoangtran ,

Thanks for contribution and collaboration.

Humble request from you whenever reporting issue,Kindly provide us exact steps to reproduce (elaborate more about it),screenshot / videos so, that it wil help us to quickly reproduce the issue.

:heavy_check_mark: Issue confirmed

Issue got reproduced in 2.4-develop branch.

Description: Url rewrite for new category in 2nd store view doesn't correctly generated when product with new category imported.

Pre-requisite: -Fresh magento 2.4-develop should be installed.

Steps to reproduce:

  1. Create a new store view.

  2. Go to Stores >> Configuration >> General >> Search Engine Optimization >> Set "Yes" in Use Web Server Rewrites.

  3. Go to System >> Data transfer >>Import ->Import a file of products and add new category in the Category column of the file (make sure that category should not be created in the backend). catalog_product.csv

  4. Now, verify the url rewrite generated for the storeview of the category in Marketing >> Seo & Search >> Url Rewrite.

Expected result: The category URL rewrite is generated for all store view. Actual result: The category URL rewrite is generated for only the default store view of the store group. Screenshots:

Screenshot 2023-03-03 at 6 09 14 PM

Hence, confirming the issue.

github-jira-sync-bot commented 1 year ago

:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-8106 is successfully created for this GitHub issue.

m2-assistant[bot] commented 1 year ago

:white_check_mark: Confirmed by @engcom-Lima. Thank you for verifying the issue.
Issue Available: @engcom-Lima, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

github-jira-sync-bot commented 1 year ago

:x: You don't have permission to export this issue.

Kannakiraj123 commented 1 year ago

@magento I am working on this

mirceaRosmeteniuc commented 1 year ago

The internal team already fixed this issue. Currently, in delivery queue.

hostep commented 1 year ago

Probably fixed by ACP2E-1737: Category URL rewrite is not generated for all store views when importing a new category from an CSV file ?

@mirceaRosmeteniuc: in the future, please do not close issues until the code is published on github and then specify in a comment the ticket number and/or links to the commits that fixed it. Thanks for understanding! 🙂