We want to update stock status with sql query. This query worked and products status does as out of stock in product page. But when i did clearing cache, products is appearing in stock

when i check products in admin panel, products is appearing in stock.

Does magento has function for product status change?

$query = "UPDATE cataloginventory_stock_status SET stock_status = 0 WHERE product_id=".$product_id;


1 Answer 1


try this query, in will prevent product appears on the website searching result and although product page can be accessed on the frontend by url, it cannot be added to cart :

$query = "UPDATE cataloginventory_stock_item SET is_in_stock = 0 WHERE product_id=".$product_id;

hope this works

  • thanks @mrfizh, this query worked. i have a one more question. How can i update stock qty with sql query? $query = "UPDATE cataloginventory_stock_status SET stock_status = 0 WHERE product_id=".$product_id; I tried this code but i don't get positive result.
    – epica
    Nov 9, 2018 at 7:15
  • glad to know it works. you can update the stock quantity by change the column on my answer above to be like this : $query = "UPDATE cataloginventory_stock_item SET qty = 100 WHERE product_id=".$product_id;
    – mrfizh
    Nov 9, 2018 at 7:20
  • okay you're welcome :)
    – mrfizh
    Nov 9, 2018 at 7:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.