Jump to content

Script for massive product delete


luca1711

Recommended Posts

Hi, I'm sorry for the trouble. I can not find valid solutions on the net, I've been looking for days.
I need to delete all products, images and everything associated with the products. I have to make a new import of products from the new catalog and I want to empty all my shop to have it fresh to insert the new catalog.
I am looking for a SQL script that can do this or a php script. I need to delete all the products from the database and from the server.
Can you give me any suggestions please?
thanks to anyone who can answer.
 

 

my version 1.6.1.12

Link to comment
Share on other sites

DELETE FROM `ps_specific_price`
DELETE FROM `ps_specific_price_priority`
DELETE FROM `ps_compare_product`
DELETE FROM `ps_product_attachment`
DELETE FROM `ps_product_country_tax`
DELETE FROM `ps_product_download`
DELETE FROM `ps_product_group_reduction_cache`
DELETE FROM `ps_product_sale`
DELETE FROM `ps_scene_products`
DELETE FROM `ps_warehouse_product_location`
DELETE FROM `ps_customization`
DELETE FROM `ps_customization_field`
DELETE FROM `ps_attribute_impact`
DELETE FROM `ps_pack`
DELETE FROM `ps_pack`
DELETE FROM `ps_stock_mvt`
DELETE FROM `ps_stock`
DELETE FROM `ps_category_product`
DELETE FROM `ps_product_attribute_image`
DELETE FROM `ps_image_lang`
DELETE FROM `ps_image_shop`
DELETE FROM `ps_image`
DELETE FROM `ps_product_supplier`
DELETE FROM `ps_feature_product`
DELETE FROM `ps_product_tag`
DELETE FROM `ps_product_carrier`
DELETE FROM `ps_cart_product`
DELETE FROM `ps_stock_mvt`
DELETE FROM `ps_stock`
DELETE FROM `ps_product_attribute_image`
DELETE FROM `ps_product_attribute_combination`
DELETE FROM `ps_product_supplier`
DELETE FROM `ps_stock_available`
DELETE FROM `ps_product_attribute_shop`
DELETE FROM `ps_product_attribute`
DELETE FROM `ps_stock_available`
DELETE FROM `ps_product_lang`
DELETE FROM `ps_product_shop`
DELETE FROM `ps_product`

 

That will remove product + images database entries. You will also need to (recursively) delete image files from img/p/* directory

Or you can use my module (see signature) to import you catalog data, and it will take care for the cleaning part.

Edited by DataKick (see edit history)
  • Thanks 1
Link to comment
Share on other sites

Thank you for your intervention. You are very kind to provide the script.

The PS Cleaner module also deletes the categories, I only need to delete the products to make a new import with empty catalog.

Now I also try your form and let you know.
Thanks so much

Link to comment
Share on other sites

  On 12/5/2017 at 8:21 AM, DataKick said:
DELETE FROM `ps_specific_price`
DELETE FROM `ps_specific_price_priority`
DELETE FROM `ps_compare_product`
DELETE FROM `ps_product_attachment`
DELETE FROM `ps_product_country_tax`
DELETE FROM `ps_product_download`
DELETE FROM `ps_product_group_reduction_cache`
DELETE FROM `ps_product_sale`
DELETE FROM `ps_scene_products`
DELETE FROM `ps_warehouse_product_location`
DELETE FROM `ps_customization`
DELETE FROM `ps_customization_field`
DELETE FROM `ps_attribute_impact`
DELETE FROM `ps_pack`
DELETE FROM `ps_pack`
DELETE FROM `ps_stock_mvt`
DELETE FROM `ps_stock`
DELETE FROM `ps_category_product`
DELETE FROM `ps_product_attribute_image`
DELETE FROM `ps_image_lang`
DELETE FROM `ps_image_shop`
DELETE FROM `ps_image`
DELETE FROM `ps_product_supplier`
DELETE FROM `ps_feature_product`
DELETE FROM `ps_product_tag`
DELETE FROM `ps_product_carrier`
DELETE FROM `ps_cart_product`
DELETE FROM `ps_stock_mvt`
DELETE FROM `ps_stock`
DELETE FROM `ps_product_attribute_image`
DELETE FROM `ps_product_attribute_combination`
DELETE FROM `ps_product_supplier`
DELETE FROM `ps_stock_available`
DELETE FROM `ps_product_attribute_shop`
DELETE FROM `ps_product_attribute`
DELETE FROM `ps_stock_available`
DELETE FROM `ps_product_lang`
DELETE FROM `ps_product_shop`
DELETE FROM `ps_product`

 

That will remove product + images database entries. You will also need to (recursively) delete image files from img/p/* directory

Or you can use my module (see signature) to import you catalog data, and it will take care for the cleaning part.

Expand  

If I delete this 

DELETE FROM `ps_category_product`

 from the script
can I save the categories?

Link to comment
Share on other sites

  On 12/6/2017 at 4:57 PM, luca1711 said:

If I delete this 

DELETE FROM `ps_category_product`

 from the script
can I save the categories?

Expand  

 

ps_category_product contains only associations between products and categories, not category data itself (ie product 1 belongs to categories 1,2,3,....)

When you delete all products, you can (and should) delete data from this table as well, as it would contain invalid entries otherwise. 

 

  • Thanks 1
Link to comment
Share on other sites

@DataKick

Hello, when I run the query you suggested I get an error for all the entries.
Did I do something wrong? Do you have any other suggestions?
However, your software is very interesting, the next few days we discuss privately this because I'm very interested and I think I'll buy the license for a year.

https://prnt.sc/hkosaz

https://prnt.sc/hkosme

Link to comment
Share on other sites

You have to run each statement separately, or add semicolon at the end of the lines: 

 

DELETE FROM `ps_specific_price`;
DELETE FROM `ps_specific_price_priority`;
DELETE FROM `ps_compare_product`;
DELETE FROM `ps_product_attachment`;
DELETE FROM `ps_product_country_tax`;
DELETE FROM `ps_product_download`;
DELETE FROM `ps_product_group_reduction_cache`;
DELETE FROM `ps_product_sale`;
DELETE FROM `ps_scene_products`;
DELETE FROM `ps_warehouse_product_location`;
DELETE FROM `ps_customization`;
DELETE FROM `ps_customization_field`;
DELETE FROM `ps_attribute_impact`;
DELETE FROM `ps_pack`;
DELETE FROM `ps_pack`;
DELETE FROM `ps_stock_mvt`;
DELETE FROM `ps_stock`;
DELETE FROM `ps_category_product`;
DELETE FROM `ps_product_attribute_image`;
DELETE FROM `ps_image_lang`;
DELETE FROM `ps_image_shop`;
DELETE FROM `ps_image`;
DELETE FROM `ps_product_supplier`;
DELETE FROM `ps_feature_product`;
DELETE FROM `ps_product_tag`;
DELETE FROM `ps_product_carrier`;
DELETE FROM `ps_cart_product`;
DELETE FROM `ps_stock_mvt`;
DELETE FROM `ps_stock`;
DELETE FROM `ps_product_attribute_image`;
DELETE FROM `ps_product_attribute_combination`;
DELETE FROM `ps_product_supplier`;
DELETE FROM `ps_stock_available`;
DELETE FROM `ps_product_attribute_shop`;
DELETE FROM `ps_product_attribute`;
DELETE FROM `ps_stock_available`;
DELETE FROM `ps_product_lang`;
DELETE FROM `ps_product_shop`;
DELETE FROM `ps_product`;

 

I'm very glad you are considering using my datakick module - as you know, there's 14 day trial period so you can try it freely. If you need any help, or have questions, just shoot me a message. Also, if you need more time evaluating the module, just let me know, I could issue a temporary license key for you.

 

 

Edited by DataKick (see edit history)
Link to comment
Share on other sites

  On 12/8/2017 at 9:37 AM, luca1711 said:

@DataKick

It had been a long time since I had put my hand to this and I am certainly committing a beginner's mistake.
Now he responds with these errors, sorry if I still ask you, but you have another trick on how to execute the query?

https://prnt.sc/hkpc4e

https://prnt.sc/hkpb07

Expand  

 

 

well, you need to choose database first. Click on the Database tab in upper left corner, and select database that contains your prestashop data. Then execute sql within this context. 

 

Alternative is to find out database name and prepend the whole script with (assuming mydbname is name of the ps database)

 

use database mydbname;

 

See this video

 

Edited by DataKick (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...