我正在编写 C# 程序,以使用供应商提供的 feed 文件更新我的 magento 商店。到目前为止,它运行得很好,但是当数量=“0”时,在店面,产品仍然显示为可用,只有当尝试购买它时,才会显示它不可用。 我的问题是,当数量=“0”时,如何将其设置为缺货。 这是我的 C# 代码:
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();
}
}
在数据库表“cataloginventory_stock_item”中,我可以看到列“is_in_stock”,将值更改为“0”并不会使店面“缺货”。 Magento 如何将产品设置为“缺货”?
最佳答案
我找到了答案,可能对其他人也有帮助。
//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 + "');"
关于c# - 如何直接在 MySQL 中更新 magento stock,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32549699/