示例#1
0
        /// <summary>
        /// Gets list of products
        /// </summary>
        public static void GetProducts()
        {
            string   sBrandId       = ConfigurationManager.AppSettings.Get("BrandID");
            Products p              = new Products();
            var      productRequest = new CloudCommercePro.Products.RequestObjectOfAPIProductGetProductListRequest();

            productRequest.BrandID      = int.Parse(sBrandId);
            productRequest.SecurityHash = GetSecurityHash();

            // begin at the start of the list of available products
            // get the first 10 products in the list
            productRequest.Content = new CloudCommercePro.Products.APIProductGetProductListRequest {
                Start = 0, End = 10, SalesChannelID = 0
            };

            var products = p.ProductsClient.getProducts(productRequest);

            if (products.Content.products != null && products.Content.products.Any())
            {
                foreach (var product in products.Content.products)
                {
                    Console.WriteLine(string.Format("ID {0} ManufacturerSKU {1} Name {2}", product.ID, product.ManufacturerSKU, product.Name));
                }

                Console.ReadKey();
            }
        }
示例#2
0
        public static void BatchStockUpateBySKU()
        {
            string sBrandId      = ConfigurationManager.AppSettings.Get("BrandID");
            int    brandId       = int.Parse(sBrandId);
            int    stockQuantity = 100;

            var productsClient = new Products().ProductsClient;


            var productRequest = new CloudCommercePro.Products.RequestObjectOfAPIProductGetProductListRequest();

            productRequest.BrandID      = int.Parse(sBrandId);
            productRequest.SecurityHash = GetSecurityHash();

            productRequest.Content = new CloudCommercePro.Products.APIProductGetProductListRequest {
                Start = 0, End = 5, SalesChannelID = 0
            };

            var products = productsClient.getProducts(productRequest);

            List <CloudCommercePro.Products.APIUpdateStockRequest> stockUpdates = new List <CloudCommercePro.Products.APIUpdateStockRequest>();

            if (products.Content.products != null && products.Content.products.Any())
            {
                foreach (var product in products.Content.products)
                {
                    stockUpdates.Add(new CloudCommercePro.Products.APIUpdateStockRequest
                    {
                        SKU             = product.ManufacturerSKU,
                        StockQuantity   = stockQuantity,
                        UpdateRealStock = true
                    });
                }
            }


            var res = productsClient.BatchStockUpdates(new CloudCommercePro.Products.RequestObjectOfAPIBulkUpdateStockRequest
            {
                BrandID      = brandId,
                SecurityHash = GetSecurityHash(),
                Content      = new CloudCommercePro.Products.APIBulkUpdateStockRequest
                {
                    StockUpdates = stockUpdates.ToArray()
                }
            });

            Console.ReadKey();
        }