{"id":2817,"date":"2020-09-04T20:36:44","date_gmt":"2020-09-04T18:36:44","guid":{"rendered":"https:\/\/davidperezgar.com\/?p=2817"},"modified":"2020-10-13T11:35:41","modified_gmt":"2020-10-13T09:35:41","slug":"delete-all-products-woocommerce-sql","status":"publish","type":"post","link":"https:\/\/davidperezgar.com\/en\/blog\/web-development\/delete-all-products-woocommerce-sql\/","title":{"rendered":"Eliminar todos los productos WooCommerce de SQL"},"content":{"rendered":"\n
Si necesitas eliminar todos los productos de tu tienda WooCommerce, ya sea porque est\u00e1s desarrollando, has hecho una importaci\u00f3n y quieres eliminarlo o quieres empezar de nuevo, puedes usar el siguiente fragmento que he encontrado y probado y que va mucho m\u00e1s r\u00e1pido cuando se ejecuta directamente en la base de datos.<\/p>\n\n\n\n
DELETE relations.*, taxes.*, terms.*\nFROM wp_term_relationships AS relations\nINNER JOIN wp_term_taxonomy AS taxes\nON relations.term_taxonomy_id=taxes.term_taxonomy_id\nINNER JOIN wp_terms AS terms\nON taxes.term_id=terms.term_id\nWHERE object_id IN (SELECT ID FROM wp_posts WHERE post_type='product');\n \nDELETE FROM wp_postmeta WHERE post_id IN (SELECT ID FROM wp_posts WHERE post_type = 'product');\nDELETE FROM wp_posts WHERE post_type = 'product';\n\nDELETE FROM wp_postmeta WHERE post_id IN (SELECT ID FROM wp_posts WHERE post_type = 'product_variation');\nDELETE FROM wp_posts WHERE post_type = 'product_variation';<\/code><\/pre>\n\n\n\nRecuerde siempre hacer una copia de la base de datos antes de trabajar con consultas tambi\u00e9n.<\/p>\n\n\n\n
He a\u00f1adido que tambi\u00e9n se eliminan las variaciones del c\u00f3digo original.<\/p>\n\n\n\n