Skip to content

Instantly share code, notes, and snippets.

@tuongpgjz
Last active January 9, 2022 10:12
Show Gist options
  • Save tuongpgjz/dd8450e9d00d556162635301f6ee1157 to your computer and use it in GitHub Desktop.
Save tuongpgjz/dd8450e9d00d556162635301f6ee1157 to your computer and use it in GitHub Desktop.
Remove all product data and product meta
-- This SQLs remove products and their meta data on your store
-- SalesGen.io
-- delete product info
DELETE FROM wp_posts WHERE post_type = 'product_variation';
DELETE FROM wp_posts WHERE post_type = 'product';
-- After remove products from posts table, must clear data in postmeta to reduce database size.
-- Delete orphan postmeta
DELETE pm
FROM wp_postmeta pm
LEFT JOIN wp_posts p ON pm.post_id = p.ID
WHERE p.ID IS NULL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment