Skip to content

Instantly share code, notes, and snippets.

@amouratoglou
Last active September 11, 2019 15:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amouratoglou/f49d6b4a7d056d22f2bc39568a554990 to your computer and use it in GitHub Desktop.
Save amouratoglou/f49d6b4a7d056d22f2bc39568a554990 to your computer and use it in GitHub Desktop.
Woocommerce product management SQL scripts
/*
Make sure you execute the script in the right database!
- Delete all products -
Description: This script deletes all WooCommerce products
and their associations (categories/taxonomies and terms info)
*/
DELETE relations.*, taxes.*, terms.*
FROM wp_term_relationships AS relations
INNER JOIN wp_term_taxonomy AS taxes
ON relations.term_taxonomy_id=taxes.term_taxonomy_id
INNER JOIN wp_terms AS terms
ON taxes.term_id=terms.term_id
WHERE object_id IN (SELECT ID FROM wp_posts WHERE post_type='product');
DELETE FROM wp_postmeta WHERE post_id IN (SELECT ID FROM wp_posts WHERE post_type = 'product');
DELETE FROM wp_posts WHERE post_type = 'product';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment