简体   繁体   English

使用C#中的magento soap API更新magento中的产品库存

[英]update product inventory in magento using magento soap api in C#

I am trying to update the Product inventory in Magento, using Magento SOAP API in C#. 我正在尝试使用C#中的Magento SOAP API更新Magento中的产品库存。 When I call the product_stock.update api, it returns true. 当我调用product_stock.update api时,它返回true。 But when I check in Magento Admin panel, it is not updated. 但是,当我在Magento管理控制台中签入时,它没有更新。

ProductInventoryStock[] arrProdInventoryStock = new ProductInventoryStock[1];
for (int iCnt = 0; iCnt < arrProdInventoryStock.Count(); iCnt++)
{
  ProductInventoryStock objProdInventoryStock = new ProductInventoryStock();
  objProdInventoryStock.qty = "111";
  objProdInventoryStock.is_in_stock = 1;
  objProdInventoryStock.manage_stock = 1;
  objProdInventoryStock.use_config_manage_stock = 0;
  arrProdInventoryStock[iCnt] = objProdInventoryStock;
}

bool test = Inventory.Update(apiUrl, sessionId, new object[] { "126", arrProdInventoryStock });

Please check this, and is there any problem over here. 请检查一下,这里是否有任何问题。 or something else? 或者是其他东西? Thanks. 谢谢。

Im using Mangento 1.9.x with the v2_soap?wsdl=1 and integrate with C# (4.5 Framework), I made a simple function that will update the stock, taking parameters as activeSession , ProductId , stockQty , stockStatus . 我将Mangento 1.9.xv2_soap?wsdl=1并与C#(4.5 Framework)集成,我做了一个简单的函数,它将更新库存,并采用activeSessionProductIdstockQtystockStatus作为参数。 Most important thing to note is that I've set the value to is_in_stock along with is_in_stockSpecified 需要注意的最重要的一点是,我将值与is_in_stock一起设置为is_in_stockSpecified

        protected void AddInventory(string activeSession, string ProductId, string stockQty, int stockStatus)
        {
        MagentoService mservice = new MagentoService();
        catalogInventoryStockItemUpdateEntity uStock = new catalogInventoryStockItemUpdateEntity();
        int stock_status=stockStatus;            
        uStock.qty = stockQty;
        uStock.is_in_stock = stock_status;
        uStock.is_in_stockSpecified = Convert.ToBoolean(stock_status);
        int result;

        try
        {                
            result = mservice.catalogInventoryStockItemUpdate(activeSession, ProductId, uStock);                
        }
        catch (Exception ex)
        {         
        }            
        }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM