-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathwoo-cleanup.sql
More file actions
14 lines (13 loc) · 838 Bytes
/
woo-cleanup.sql
File metadata and controls
14 lines (13 loc) · 838 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# cleanup all products and categories from WooCommerce
DELETE FROM {dbprefix}term_relationships WHERE object_id IN (SELECT ID FROM {dbprefix}posts WHERE post_type = 'product');
DELETE FROM {dbprefix}postmeta WHERE post_id IN (SELECT ID FROM {dbprefix}posts WHERE post_type = 'product');
DELETE FROM {dbprefix}posts WHERE post_type = 'product';
# To remove the taxonomies (which store the name of the attribute) and the terms
# (which store the values) as well, you can use the following query
DELETE relations.*, taxes.*, terms.*
FROM {dbprefix}term_relationships AS relations
INNER JOIN {dbprefix}term_taxonomy AS taxes
ON relations.term_taxonomy_id=taxes.term_taxonomy_id
INNER JOIN {dbprefix}terms AS terms
ON taxes.term_id=terms.term_id
WHERE object_id IN (SELECT ID FROM {dbprefix}posts WHERE post_type='product');