
March 14, 2010 12:16 by
Need to use product_id and not sku! use sku to get item and then set product_id
one example of one item.
public string UpdateInventory(string sku, int inStock, string stkQty) { if (string.IsNullOrEmpty(this.SessionId)) this.Login();
try { string prodID = string.Empty ; catalogInventoryStockItemEntity ie = new catalogInventoryStockItemEntity(); MagentoPushPullService.MagentoWebService.catalogInventoryStockItemUpdateEntity cisi = new catalogInventoryStockItemUpdateEntity(); cisi.is_in_stock = inStock; cisi.qty = stkQty; cisi.is_in_stockSpecified = true; // you can pass in more than one product at a time by setting/passing in an array of strings string[] item = new string[1] ; item[0] = sku; foreach (catalogInventoryStockItemEntity sie in magentoService.catalogInventoryStockItemList(this.SessionId,item)) { prodID = sie.product_id ; }
// Update product by product id from StockItemList call int i; i = magentoService.catalogInventoryStockItemUpdate(this.SessionId, prodID, cisi);
foreach (catalogInventoryStockItemEntity sie in magentoService.catalogInventoryStockItemList(this.SessionId, item)) { string tmp = sie.is_in_stock; }
return "Success"; } catch (Exception ex) { //TODO: Log the error return "Error updating inventory"; } }
|
e76606e7-7fbf-46fb-90ae-d73ba4150757|1|5.0