I'm writing C# program, to update my magento store using feed files from suppliers. So far it works very well, but when quantity = "0", on storefront, product is still shown as available, only when trying to buy it, says it's not available.
My question is, how set it to out of stock, when quantity = "0".
Here is my C# code:
public void updateHB(string sku, string qty, string price)
{
try
{
connect.Open();
MySqlCommand query = new MySqlCommand(
//update qty
"update cataloginventory_stock_item set qty = '" + qty + "' " +
"where cataloginventory_stock_item.product_id = " +
"(select catalog_product_entity.entity_id from catalog_product_entity where sku ='" + sku + "');" +
//update price, stock price + 15%
"update catalog_product_entity_decimal set value = (" + price + " * 1.15) " +
"where catalog_product_entity_decimal.attribute_id = '75' and " +
"catalog_product_entity_decimal.entity_id = " +
"(select catalog_product_entity.entity_id from catalog_product_entity where sku ='" + sku + "');"
, connect);
query.ExecuteNonQuery();
connect.Close();
successMSG(sku);
}
catch
{
errorMSG();
}
}
In database table "cataloginventory_stock_item" i can see column "is_in_stock", changing value to "0" doesn't make it "Out Of Stock" on storefront.
How Magento sets products to "Out Of Stock"?
Solutions1
I found the answer, may be helpful for some one else as well.
//set available in stock = 1; out of stock = 0;
"update cataloginventory_stock_status set stock_status = '1' " +
"where cataloginventory_stock_status.product_id = " +
"(select catalog_product_entity.entity_id from catalog_product_entity where sku ='" + sku + "');"