Eliminar productos y atributos de WooCommerce de forma masiva

Si por algún motivo quieres eliminar todos los productos o atributos de una tienda con WooCommerce de forma masiva puedes usar los siguientes comandos SQL.

Eliminar todos los atributos de WooCommerce

DELETE FROM wp_terms WHERE term_id IN 
(SELECT term_id FROM wp_term_taxonomy WHERE taxonomy LIKE 'pa_%');
DELETE FROM wp_term_taxonomy WHERE taxonomy LIKE 'pa_%';
DELETE FROM wp_term_relationships WHERE term_taxonomy_id not IN 
(SELECT term_taxonomy_id FROM wp_term_taxonomy);

Eliminar todos los productos de WooCommerce

DELETE FROM wp_term_relationships WHERE object_id IN 
(SELECT ID FROM wp_posts WHERE post_type IN ('product','product_variation'));
DELETE FROM wp_postmeta WHERE post_id IN (SELECT ID FROM wp_posts WHERE post_type IN 
('product','product_variation'));
DELETE FROM wp_posts WHERE post_type IN ('product','product_variation');

Si el prefijo de las tablas de tu WordPress no es wp_ reemplázalo donde corresponda wp_terms > prefijo_terms

Fuente: mindyourownwebsite.com

Deja un comentario