How to Clear WooCommerce Orphaned Post_Meta

  Only Peter Understands These

When you see this error:

The SKU (xxx) you are trying to insert is already under processing [woocommerce_rest_product_not_created] error

Login to the website’s mysql as root this way:

mysql -u root -p
show databases;
use [wp database];

Try the following queries to clear meta data for products that no longer exist.

DELETE wp_wc_product_meta_lookup
FROM wp_wc_product_meta_lookup
LEFT JOIN wp_posts ON wp_wc_product_meta_lookup.product_id = wp_posts.ID
WHERE wp_posts.ID IS NULL;
DELETE wp_postmeta
FROM wp_postmeta
LEFT JOIN wp_posts ON wp_postmeta.post_id = wp_posts.ID
WHERE wp_posts.ID IS NULL;

Don’t forget to exit mysql this way:

exit;

LEAVE A COMMENT