-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Description
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.