Jump to content

Script to add and remove products from the database


Recommended Posts

Hi,

I have built a couple of webshops using prestashop. One of them has a stock feed that changes rapidly I am not very keen on importing and deleting the data manually every time. Is there any php script or command line tool available that creates a product in the database and removes the inactive ones.

I did a bit of research in deleting a product from a database and I have a script ready but I am absolutely not sure if I am not messing things up on the db level :)

Any help would be greatly appreciated.

Link to comment
Share on other sites

  • 1 year later...

Probably too late for you, but for anyone else, based on truncates in AdminImport version 1.4.4.1 here is sql I just used to delete inactive products... as always make a backup, etc...

 

DELETE FROM ps_feature_product WHERE id_product IN (SELECT id_product from ps_product WHERE active=0);
DELETE FROM ps_product_lang WHERE id_product IN (SELECT id_product from ps_product WHERE active=0);
DELETE FROM ps_category_product WHERE id_product IN (SELECT id_product from ps_product WHERE active=0);
DELETE FROM ps_product_tag WHERE id_product IN (SELECT id_product from ps_product WHERE active=0);
DELETE FROM ps_image_lang WHERE id_image IN (SELECT id_image from ps_image i LEFT JOIN ps_product p ON i.id_product=p.id_product WHERE p.active=0);
DELETE FROM ps_image WHERE id_product IN (SELECT id_product from ps_product WHERE active=0);
DELETE FROM ps_specific_price WHERE id_product IN (SELECT id_product from ps_product WHERE active=0);
DELETE FROM ps_specific_price_priority WHERE id_product IN (SELECT id_product from ps_product WHERE active=0);
DELETE FROM ps_product WHERE active=0;

Link to comment
Share on other sites

  • 2 months later...

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...