What if you have added a lot of pictures for each product on your store site to make it user-friendly and attractive but you encounter a situation in which you have to delete all those pictures in bulk for several products? Majority of store owners would have to spend hours deleting pictures one by one for each product because nopCommerce does not offer any option out of the box to delete product pictures in bulk.
Today, we will discuss a workaround that can save your time and effort to bulk delete images for a product (or products).
Requirement: You will need access to your SQL database for the store site in order to perform this task.
Connect to the server and open your SQL database.
We need to know 3 things:
- Products are saved in the "Product" table
- Product and image mapping in maintained in "Product_Picture_Mapping" table
- We need to know the product ID for the item (or product) for which we would like to delete images
Here is a screenshot of "Product_Picture_Mapping" table, so that you can get an idea of how products are being mapped to their respective pictures.
Use this SQL query to bulk delete images for a product:
DELETE FROM Picture
WHERE [Id] in (SELECT PictureId FROM Product_Picture_Mapping WHERE ProductId = 'Enter_Product_ID');
Note: Replace 'Enter_Product_ID' with your product id.
Run this query against your database and all the product pictures will be delete to that particular product for which you entered the "ID" like this:
That's all - Now, if you go to your public store and check the product, you won't see any picture for that product. You can repeat this product for all the products for which you would like to delete pictures.