Disable out of stock product
hi, in PS I’m using MySql Trigger method (https://mypresta.eu/en/art/tips-and-tricks/how-to-disable-out-of-stock-product.html) to disable out of stock product, but after migrate to 30bz and enable multistore, this method doesn’t work anymore. any idea?
I suspect this is a table name issue. The sample code uses the default PS table names which start with
ps_while 30bz default table names begin with
tb_. If you modify the code to match your table names it should still work:
CREATE TRIGGER change_active_after_update AFTER UPDATE ON tb_stock_available FOR EACH ROW BEGIN UPDATE tb_product_shop SET active=0 WHERE id_product IN (SELECT id_product FROM tb_stock_available WHERE quantity=0); UPDATE tb_product_shop SET active=1 WHERE id_product IN (SELECT id_product FROM tb_stock_available WHERE quantity>0); END
Of course if you are using non-standard table names then you will need to modify the code above to match your tables.
Thanks for the tips, I have recheck and found the trouble in my database. db_stock and db_stock_available not sync well.