MySQL如何设置为无货_如何直接在MySQL中更新Magento库存

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 + "');"

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值