Jump to content

SQL Trigger to add Product to a category based on quantity


Recommended Posts



I just wanted to see if anyone is able to help work out a Trigger that will add an item to a specifc category based on quantity?


I have a section on the website that shows all stock that only has 1 left.


I'm fairly new to SQL and i've tried to merge 2 different sql triggers to make it work, but i keep getting errors

UPDATE ps_product, ps_product_shop SET ps_product.id_category_default = '216', ps_product_shop.id_category_default = '216' WHERE id_product IN (SELECT id_product FROM ps_stock_available WHERE quantity=1);

If anyone is able to help, that'll be great.



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

It is not only ps_product and ps_product_shop to handle. The most important is also to handle the table ps_category_product.

Furthermore you should consider doing the opposite if necessary => quantity is zero or more than 1.

If desired we can work this out for you as paid job.

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