-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Description
With a catalog of many thousands of products loaded, saving a category causes long execution times and high memory usage, when it isn't necessarily required. In a production environment, the execution fails with max_execution_time or memory_limit errors.
It appears that the system is trying to regenerate all URLs of products contained within the category and subcategories; even if the url_key is not modified.
Preconditions
- Magento 2.1.1
max_execution_timeset to 300memory_limitset to 2G- Catalog of 140,000 products
- Top category which contains subcategories and 40,000+ products
Steps to reproduce
- Simply "Save" the top category without even making any changes
Expected result
- No errors
- A notice of
You saved the categoryshould appear
Actual result
- PHP errors for
max_execution_timeand/ormemory_limit
A workaround is to modify /vendor/magento/module-catalog-url-rewrite/Observer/CategoryProcessUrlRewriteSavingObserver.php temporarily to return; on line 1 of the execute() function to prevent URL rewrite changes.
A suggested performance improvement would be to check if the url_key was modified before running the regeneration of URLs.
This, though, cannot be used if the url_key is updated. At that point, the process should be handled by some background task.