Deleting 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 commercetools platform commands.
Imagine we have 5 products in the project which we would like to delete, such as the products shown in the image below.
But we don't want to waste time in deleting one product by one in the Merchant Center, we rather look for a way to delete all the products in one step.
From there we select the IMPEX Product State command that we are going to use for deleting the products like shown below:
Once we are on the
Product status 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 the project in the Merchant Center .
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 the 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.
To be really sure that all products have been removed from the project we can verify their absence in the Merchant Center . If the Products page looks empty like the one shown below you have succeeded in deleting all your products.