Reputation: 1
I am trying to update the Product inventory in Magento, using Magento SOAP API in C#. When I call the product_stock.update api, it returns true. But when I check in Magento Admin panel, it is not updated.
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.
Upvotes: 0
Views: 1243
Reputation: 11
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
. Most important thing to note is that I've set the value to is_in_stock
along with 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)
{
}
}
Upvotes: 1