Recently I was working on a very large WooCommerce store trying to find out why it was so slow. As part of the troublshooting process I switched themes and then noticed the load on the debugging server went insanely high. After a Google search I learned that WooCommerce will automatically regenerate all product image thumbnails when you change theme!
This particular store had 40,000 products so I was not interested in waiting for it to complete. Luckily somebody had already detailed how to stop the batch product image thumbnail process in WooCommerce here so I have adapted the solution with WP-CLI.
How to Stop WooCommerce Product Image Regeneration with WP-CLI
You can find the batch thing in the database
wp db query "SELECT * FROM $(wp db prefix --allow-root)options WHERE option_name LIKE '%\_batch\_%'" --allow-root
– Delete the option with the value that looks like a:4757:{i:11165;a:1:{s:13:”attachment_id”;s:5:”12976″;}
wp db query "DELETE FROM $(wp db prefix --allow-root)options WHERE option_name LIKE '%\_batch\_%'" --allow-root
We can also delete the cronjob that is running
wp cron event list --allow-root
See the wp_1_wc_regenerate_images_cron
below which recurs every 5 minutes
+-------------------------------------------+---------------------+-------------------------+---------------+
| action_scheduler_run_queue | 2019-08-22 17:16:08 | 38 sekunder | 1 minut |
| wp_1_wc_regenerate_images_cron | 2019-08-22 17:20:24 | 4 minutter 54 sekunder | 5 minutter |
| woocommerce_cancel_unpaid_orders | 2019-08-22 17:29:18 | 13 minutter 48 sekunder | Non-repeating |
| wpwoof_feed_update | 2019-08-22 17:56:17 | 40 minutter 47 sekunder | 12 timer |
| wpseo-premium-prominent-words-recalculate | 2019-08-22 18:04:57 | 49 minutter 27 sekunder | 1 dag |
| wpseo-reindex-links | 2019-08-22 18:33:07 | 1 time 17 minutter | 1 dag |
| woocommerce_cleanup_logs | 2019-08-22 20:09:18 | 2 timer 53 minutter | 1 dag |
| ao_cachechecker | 2019-08-22 21:47:45 | 4 timer 32 minutter | 12 timer |
| woocommerce_scheduled_sales | 2019-08-22 22:00:00 | 4 timer 44 minutter | 1 dag |
| woocommerce_cleanup_sessions | 2019-08-22 23:09:18 | 5 timer 53 minutter | 12 timer |
| wp_version_check | 2019-08-22 23:33:55 | 6 timer 18 minutter | 12 timer |
| wp_update_plugins | 2019-08-22 23:33:55 | 6 timer 18 minutter | 12 timer |
| wp_update_themes | 2019-08-22 23:33:55 | 6 timer 18 minutter | 12 timer |
| wp_privacy_delete_old_export_files | 2019-08-23 02:33:55 | 9 timer 18 minutter | 12 timer |
| facetwp_cache_cleanup | 2019-08-23 03:12:23 | 9 timer 56 minutter | 1 dag |
| fs_data_sync_content-aware-sidebars | 2019-08-23 03:58:24 | 10 timer 42 minutter | 1 dag |
| recovery_mode_clean_expired_keys | 2019-08-23 08:23:58 | 15 timer 8 minutter | 1 dag |
| wp_scheduled_delete | 2019-08-23 11:45:49 | 18 timer 30 minutter | 1 dag |
| delete_expired_transients | 2019-08-23 11:45:49 | 18 timer 30 minutter | 1 dag |
| wp_scheduled_auto_draft_delete | 2019-08-23 11:45:58 | 18 timer 30 minutter | 1 dag |
| woocommerce_cleanup_personal_data | 2019-08-23 17:09:18 | 23 timer 53 minutter | 1 dag |
| woocommerce_tracker_send_event | 2019-08-23 17:09:28 | 23 timer 53 minutter | 1 dag |
| fl_builder_notifications_event | 2019-08-24 10:34:49 | 1 dag 17 timer | Non-repeating |
| woocommerce_geoip_updater | 2019-09-03 00:00:00 | 1 uge 4 dage | 1 måned |
| publish_future_post | 7254-02-15 00:06:00 | 5237 år 11 måneder | Non-repeating |
| publish_future_post | 7254-02-15 00:06:00 | 5237 år 11 måneder | Non-repeating |
| publish_future_post | 7254-02-15 00:06:00 | 5237 år 11 måneder | Non-repeating |
| publish_future_post | 7254-02-15 00:06:00 | 5237 år 11 måneder | Non-repeating |
| publish_future_post | 7254-02-15 00:06:00 | 5237 år 11 måneder | Non-repeating |
| publish_future_post | 7254-02-15 00:06:00 | 5237 år 11 måneder | Non-repeating |
| publish_future_post | 7254-02-15 00:06:00 | 5237 år 11 måneder | Non-repeating |
| publish_future_post | 7254-02-15 00:06:00 | 5237 år 11 måneder | Non-repeating |
| publish_future_post | 7254-02-15 00:06:00 | 5237 år 11 måneder | Non-repeating |
| publish_future_post | 7254-02-15 00:06:00 | 5237 år 11 måneder | Non-repeating |
| publish_future_post | 7254-02-15 00:06:00 | 5237 år 11 måneder | Non-repeating |
| publish_future_post | 7254-02-15 00:06:00 | 5237 år 11 måneder | Non-repeating |
| publish_future_post | 7254-02-15 00:06:00 | 5237 år 11 måneder | Non-repeating |
| publish_future_post | 7254-02-15 00:06:00 | 5237 år 11 måneder | Non-repeating |
| publish_future_post | 7254-02-15 00:06:00 | 5237 år 11 måneder | Non-repeating |
| publish_future_post | 7254-02-15 00:06:00 | 5237 år 11 måneder | Non-repeating |
| publish_future_post | 7254-02-15 00:06:00 | 5237 år 11 måneder | Non-repeating |
| publish_future_post | 7254-02-18 00:06:00 | 5237 år 11 måneder | Non-repeating |
| publish_future_post | 7254-02-18 00:06:00 | 5237 år 11 måneder | Non-repeating |
| publish_future_post | 7254-02-18 00:06:00 | 5237 år 11 måneder | Non-repeating |
| publish_future_post | 7254-02-18 00:06:00 | 5237 år 11 måneder | Non-repeating |
| publish_future_post | 7254-02-18 00:06:00 | 5237 år 11 måneder | Non-repeating |
| publish_future_post | 7254-02-18 00:06:00 | 5237 år 11 måneder | Non-repeating |
| publish_future_post | 7254-02-18 00:06:00 | 5237 år 11 måneder | Non-repeating |
| publish_future_post | 7254-02-18 00:06:00 | 5237 år 11 måneder | Non-repeating |
| publish_future_post | 7254-02-18 00:06:00 | 5237 år 11 måneder | Non-repeating |
+-------------------------------------------+---------------------+-------------------------+---------------+
You can delete this cronjob to prevent the batch WooCommerce product image re-generation
wp cron event delete wp_1_wc_regenerate_images_cron --allow-root
There may be one with a similar name but has _interval
appended, if you see this you can delete it with this command
wp cron event delete wp_1_wc_regenerate_images_cron_interval --allow-root
Now you can get on with your troubleshooting without resources being sucked up by WooCommerce 🙂