Skip to content

Detaching category from product causes massive product url regeneration #18144

@bartoszkubicki

Description

@bartoszkubicki

Preconditions

  1. Magento 2.2.5
  2. PHP 7.1

Steps to reproduce

  1. Have large catalog - I tested it against medium profile
  2. Open product form of any product
  3. Detach category, which has a lot of product (possibly some low level one, inheriting straight from root)
  4. Save product

Expected result

  1. Product saved in some fait time, max a few seconds.

Actual result

  1. Products saving about 3-4 minutes.

Actually I have debug it and this is trace to track the problem
https://github.com/magento/magento2/blob/2.2/app/code/Magento/Catalog/Controller/Adminhtml/Product/Save.php:113
https://github.com/magento/magento2/blob/2.2/app/code/Magento/Catalog/Model/CategoryLinkManagement.php:assignProductToCategories()
https://github.com/magento/magento2/blob/2.2/app/code/Magento/Catalog/Model/CategoryLinkRepository.php:deleteByIds() -> which triggers event catalog_category_save_after
Observer https://github.com/magento/magento2/blob/2.2/app/code/Magento/CatalogUrlRewrite/Observer/CategoryProcessUrlRewriteSavingObserver.php - lines 112-3 triggers regeneration of all saved category's products. For example for first level category of catalog having 30k products it can be 5-10k products.

Whole process is completely pointless - removing category from one product triggers massive url rewrites regeneration, which is processed during http request.

Metadata

Metadata

Assignees

Labels

Component: CatalogIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releaseReproduced on 2.3.xThe issue has been reproduced on latest 2.3 release

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions