Product not to sell if stock = 0

Hello team,
I am having this problem so long but its becoming critical.
Currently - if stock = 0, product to sell still can select, since I have setup module to add product if have stock its ok.
But now the issue is I have over 5000 products and most are out of stock but when creating invoice they are showing in the list of products to add.
this is really creating problem while invoicing.

Need solution to auto set product not for sell if stock is 0
How can we do that via script so that it can run automatically or via cron job any suggestion with codes tq.

1 Like

Hi Nazeer,
We had a similar issue recently. I approached this issue pretty unusual way.
Depending on the environment you’re running the application (I will assume Linux & MySQL, like in my case)
You can set up an automatic background job on your server (with whatever frequency is applicable to you) which will execute a file on your server that contains an SQL statement which therefore would do the stock level check and in case of detection e.g. 0 or less it would set “Not for sale” in your DB.
Basically, this procedure just executes an SQL update statement and does everything automatically.

Works very smooth in our case.

If you need the syntax of the query or more details let me know!

Cheers!

Hi Waltber,
I too have the same problem and I would like you to give me the syntax of the query please.
Thank you very much and have a great day :wink: