{"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\n

Recuerde 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

V\u00eda WPFluent<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"

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. Recuerde siempre hacer […]<\/p>\n","protected":false},"author":1,"featured_media":2335,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_seopress_robots_primary_cat":"","_seopress_titles_title":"","_seopress_titles_desc":"Si necesitas eliminar todos los productos de tu tienda WooCommerce, ya sea porque est\u00e1s desarrollando, has realizado una importaci\u00f3n y deseas eliminarla.","_seopress_robots_index":"","inline_featured_image":false,"footnotes":""},"categories":[168],"tags":[],"class_list":["post-2817","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-web-development"],"_links":{"self":[{"href":"https:\/\/davidperezgar.com\/en\/wp-json\/wp\/v2\/posts\/2817","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/davidperezgar.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/davidperezgar.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/davidperezgar.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/davidperezgar.com\/en\/wp-json\/wp\/v2\/comments?post=2817"}],"version-history":[{"count":0,"href":"https:\/\/davidperezgar.com\/en\/wp-json\/wp\/v2\/posts\/2817\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/davidperezgar.com\/en\/wp-json\/wp\/v2\/media\/2335"}],"wp:attachment":[{"href":"https:\/\/davidperezgar.com\/en\/wp-json\/wp\/v2\/media?parent=2817"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/davidperezgar.com\/en\/wp-json\/wp\/v2\/categories?post=2817"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/davidperezgar.com\/en\/wp-json\/wp\/v2\/tags?post=2817"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}