How to I delete a bulk of Products?
You are looking for a way to delete a bulk of products in one step? In this tutorial we walk you through a convenient way for doing this with one of the powerful commercetools™ platform commands.
- Products to be deleted
- Product state command
- Unpublish Products
- Delete Products
- Verify deleted Products
Products to be deleted
Imagine we have 5 products in our project which we would like to delete, such as the products shown in the image below.
Product state command
From there we select the Product state command that we are going to use for deleting our products like shown below:
Once we are on the
Product state page we need to provide the credentials for the project in which we want to delete the products. We’ll get those from the
Developers section of our project in the ↗ Admin Center EU
(or ↗ Admin Center US
Before we actually delete the products we need to unpublish them. For doing this, we select the
unpublish option in the
Optional command arguments section as depicted in the figure below before we click the
Run command button.
The response will look like in the image below, indicating that all 5 products have been unpublished.
Once we have unpublished all products in our project we are now ready to delete them. This time we’ll set the option in the pick list to
delete before we hit the
Run command button.
For deleting all products (as we do in this tutorial) we do not put any file onto the ‘drop file’ area. This is required for deleting particular products only. In that case we would put a simple CSV file there that contains only one column with the header ‘SKU’. Into that column we’d list the SKUs of the particular products we’d like to delete. If we wanted to delete only 3 products out of 5 we had to list the SKU of those products in a CSV file like the one shown below:
Applying this CSV file to the
delete command would lead to the deletion of products 1, 3, and 5 whereas products 2 and 4 would remain in the project.
If everything went well we’ll get a response like the one below confirming that all 5 products have been deleted successfully.
Verify deleted Products
To be really sure that all products have been removed from our project we can verify their absence in the ↗ Admin Center EU (or ↗ Admin Center US ). If the Products page looks empty like the one shown below you have succeeded in deleting all your products.