magento2: Detaching category from product causes massive product url regeneration
Preconditions
- Magento 2.2.5
- PHP 7.1
Steps to reproduce
- Have large catalog - I tested it against medium profile
- Open product form of any product
- Detach category, which has a lot of product (possibly some low level one, inheriting straight from root)
- Save product
Expected result
- Product saved in some fait time, max a few seconds.
Actual result
- 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.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 8
- Comments: 19 (12 by maintainers)
@magento-engcom-team If you tell me how to fix it I could prepare pull request. I need information how te rearrange events or observers, because maybe sometimes this operation should be done (i mean regeneration of product urls). Maybe if we can do it in 2.3 we could put url regeneration on queue?
Anyway, I think we should remove all-product regeneration from category save and add that observer maybe to more accurate operations and events.
Hello @bartoszkubicki @jakoblundsted @pemann @Jakhotiya @hostep
Thank you for contribution and collaboration!
The corresponding internal ticket
MAGETWO-95176was fixed, delivered and closed by Magento teamPlease see details in the next commits:
@cpartica I think all question you’ve asked have been already resolved while describing the issue:
catalog_category_save_after).