Guest User

Untitled

a guest
Nov 21st, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. WebServicePortClient Client = new WebServicePortClient();
  2. Client.Solution_Connect("username", "password");
  3. Client.Solution_SetLanguage(language);
  4. Client.Product_SetFields("Id, Title, Stock, ItemNumber");
  5. Product[] products = Client.Product_GetAll();
  6.  
  7. foreach (Product myproduct in products)
  8. {
  9.  
  10.  
  11. if (myproduct.ItemNumber == "BTL1019")
  12. {
  13. writeToLog("BTL1019 found");
  14.  
  15. ProductStockUpdate updateProduct = new ProductStockUpdate();
  16. updateProduct.Id = myproduct.Id.ToString();
  17. updateProduct.Stock = 100;
  18.  
  19.  
  20.  
  21. SaveResult[] updatedResults = Client.Product_Update(new sObject[] { updateProduct });
  22.  
  23.  
  24.  
  25. if (updatedResults[0].success)
  26. {
  27. string id = updatedResults[0].id;
  28. writeToLog("<br/>ID:" + id);
  29. writeToLog("Stock:<br/>" + updateProduct.Stock);
  30. writeToLog("<br/>UPDATE Product Successfully!!!");
  31. }
  32. else
  33. {
  34. string result = updatedResults[0].errors[0].message;
  35. writeToLog("<br/>ERROR:" + result);
  36. }
  37. }
  38.  
  39.  
  40. writeToLog(myproduct.ItemNumber + " / " + myproduct.Stock);
  41. }
Add Comment
Please, Sign In to add comment