November 2, 2022 | Posted in WordPress
To understand why you would need to delete products from your WooCommerce store, let us first highlight why you would want to delete them in the first place.
Let’s say you imported products for a supper market, and that is more than twenty thousand. You have found that most products didn’t import with the accurate price, the SKU is incorrect, or something else. And you found actual errors in the CVS file.
In this scenario, fix the CVS file and import again. To do that, you need to delete all the existing products.
Every primary season, inventory is replenished with new clothing items. The old stock must be deleted so it will no longer be available.
To avoid expenditures on unsold inventory, you should dispose of products that aren’t selling.
Using the default WooCommerce setting and calling an SQL command, we will show you how to delete all products from your WooCommerce store in this part.
From your WordPress admin dashboard, go to WooCommerce > Products.
Then you need to select the option Screen Options on the top right of the Products page. Here, you could reduce the number of items per page to 100-200 products per page to speed up the deletion process since more products mean slower loading.
You must now choose the products you wish to remove from your WooCommerce store. You can do this one by one or use filters based on category, stock status, and product type.
Step 1: Log in to the phpMyAdmin
Step 2: Select the database
Select the database containing all of the products you wish to delete from the phpMyAdmin screen.
Step 3: Run the SQL statement
Here’s what you should see when you click on the SQL tab
Delete all products in your WooCommerce store by pasting the following code into the MySQL query. Click on the Go button.
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 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');
Keeping your WooCommerce store organized and up-to-date by deleting all products that are no longer sellable is essential.