/// <summary> /// Updates the specified product on the specified account using the inventory collection. /// <para>If you're updating any of the supported properties in a product, be sure to use the inventory.set /// method, for performance reasons.</para> /// </summary> private void UpdateProductUsingInventory(ulong merchantId, String productId) { Console.WriteLine("================================================================="); Console.WriteLine(String.Format("Updating product using Inventory {0}", productId)); Console.WriteLine("================================================================="); InventorySetRequest body = new InventorySetRequest(); body.Availability = "out of stock"; body.Price = new Price(); body.Price.Currency = "USD"; body.Price.Value = "3.00"; service.Inventory.Set(body, merchantId, productId.Split(':').First(), productId).Execute(); Console.WriteLine("Product updated with ID \"{0}\".", productId); Console.WriteLine(); }
/// <summary> /// Updates price and availability of a product in your Merchant Center account. This operation does not update the expiration date of the product. This method can only be called for non-multi-client accounts. /// Documentation https://developers.google.com/shoppingcontent/v2/reference/inventory/set /// Generation Note: This does not always build corectly. Google needs to standardise things I need to figuer out which ones are wrong. /// </summary> /// <param name="service">Authenticated Shoppingcontent service.</param> /// <param name="merchantId">The ID of the managing account.</param> /// <param name="storeCode">The code of the store for which to update price and availability. Use online to update price and availability of an online product.</param> /// <param name="productId">The ID of the product for which to update price and availability.</param> /// <param name="body">A valid Shoppingcontent v2 body.</param> /// <param name="optional">Optional paramaters.</param> /// <returns>InventorySetResponseResponse</returns> public static InventorySetResponse Set(ShoppingcontentService service, string merchantId, string storeCode, string productId, InventorySetRequest body, InventorySetOptionalParms optional = null) { try { // Initial validation. if (service == null) { throw new ArgumentNullException("service"); } if (body == null) { throw new ArgumentNullException("body"); } if (merchantId == null) { throw new ArgumentNullException(merchantId); } if (storeCode == null) { throw new ArgumentNullException(storeCode); } if (productId == null) { throw new ArgumentNullException(productId); } // Building the initial request. var request = service.Inventory.Set(body, merchantId, storeCode, productId); // Applying optional parameters to the request. request = (InventoryResource.SetRequest)SampleHelpers.ApplyOptionalParms(request, optional); // Requesting data. return(request.Execute()); } catch (Exception ex) { throw new Exception("Request Inventory.Set failed.", ex); } }
/// <summary> /// Updates the specified product on the specified account using the inventory collection. /// <para>If you're updating any of the supported properties in a product, be sure to use the inventory.set /// method, for performance reasons.</para> /// </summary> private void UpdateProductUsingInventory(ulong merchantId, String productId) { Console.WriteLine("================================================================="); Console.WriteLine(String.Format("Updating product using Inventory {0}", productId)); Console.WriteLine("================================================================="); InventorySetRequest body = new InventorySetRequest(); body.Availability = "out of stock"; body.Price = new Price(); body.Price.Currency = "USD"; body.Price.Value = "3.00"; InventorySetResponse response = service.Inventory.Set(body, merchantId, productId.Split(':').First(), productId).Execute(); Console.WriteLine("Product updated with ID \"{0}\".", productId); Console.WriteLine(); }