Eliminar todos los productos WooCommerce de SQL

Si necesitas eliminar todos los productos de tu tienda WooCommerce, ya sea porque estás desarrollando, has hecho una importación y quieres eliminarlo o quieres empezar de nuevo, puedes usar el siguiente fragmento que he encontrado y probado y que va mucho más rápido cuando se ejecuta directamente en la base de datos.

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';

DELETE FROM wp_postmeta WHERE post_id IN (SELECT ID FROM wp_posts WHERE post_type = 'product_variation');
DELETE FROM wp_posts WHERE post_type = 'product_variation';

Recuerde siempre hacer una copia de la base de datos antes de trabajar con consultas también.

He añadido que también se eliminan las variaciones del código original.

Vía WPFluent

2 thoughts on “Eliminar todos los productos WooCommerce de SQL”

Leave a Comment

LAtest articles

Cierre Ventana

How to prepare your plugin for the WordPress.org directory

At the WordCamp Europe in Krakow, Fran Torres and I were speakers. Just after lunch, with the audience…

Cierre Ventana

Preview plugins in WordPress Playground directly from the Pull Request

When someone opens a PR in a WordPress plugin, the usual process for reviewing it involves downloading the…

Cierre Ventana

3 years in the WordPress.org Team Plugins

Yesterday, May 5, 2026, I celebrate 3 years as part of the WordPress.org Plugins Team. And this last…