Ejemplo n.º 1
0
        /// <summary>
        /// by upc or sku
        /// </summary>
        /// <param name="product">must contain upc or sku</param>
        public static void Do(Product product)
        {
            Remix.Server server = new Remix.Server("", "");
            Remix.Products remixProducts = null;
            if (!string.IsNullOrEmpty(product.UPC))
                remixProducts = server.GetProduct(product.UPC);
            else if (!string.IsNullOrEmpty(product.BBYSKU))
                remixProducts = server.GetProduct(product.BBYSKU, false);

            if (remixProducts != null && remixProducts.Count > 0)
            {
                Remix.Product p = remixProducts[0];
                product.BBYSKU = p.Sku;
                product.UPC = p.UPC;
                product.Name = p.Name;
                product.BBYCategoryPath = p.CategoryPath.ToArray();
                product.LargeImageUrl = string.IsNullOrEmpty(p.LargeFrontImageUrl) ?
                    p.LargeImageUrl : p.LargeFrontImageUrl;
                product.LargeImageUrl = string.IsNullOrEmpty(product.LargeImageUrl) ?
                    p.ImageUrl : product.LargeImageUrl;
                product.ThumbnailImageUrl = string.IsNullOrEmpty(p.ImageUrl) ?
                    p.ThumbnailimageUrl : p.ImageUrl;
                product.BBYUrl = p.BBYUrl;
                product.BBYCJAffiliateUrl = p.CJAffiliateUrl;
                product.BBYClassId = p.ClassId;
                product.BBYClassName = p.Class;
                product.BBYSubClassId = p.SubclassId;
                product.BBYSubClassName = p.Subclass;

                int.TryParse(p.CustomerReviewCount, out product.BBYCustomerReviewCount);
                decimal.TryParse(p.CustomerReviewAverage, out product.BBYCustomerReviewAverage);

                product.Desc = p.LongDescription;
                product.DescShort = p.ShortDescription;
                decimal.TryParse(p.SalePrice, out product.BBYSalePrice);
                decimal.TryParse(p.RegularPrice, out product.BBYRegularPrice);

                int.TryParse(p.SalesRankLongTerm, out product.BBYSalesRankLongTerm);
                int.TryParse(p.SalesRankMediumTerm, out product.BBYSalesRankMediumTerm);
                int.TryParse(p.SalesRankShortTerm, out product.BBYSalesRankShortTerm);

                if (p.RelatedProducts != null)
                {
                    foreach (var sku in p.RelatedProducts)
                    {
                        product.SimilarProducts.Add(new Product() { BBYSKU = sku });
                    }
                }

                if (p.Accessories != null)
                {
                    foreach (var sku in p.Accessories)
                    {
                        product.Accessories.Add(new Product() { BBYSKU = sku });
                    }
                }
            }
        }
        public static void Do(Products products, Remix.Category category)
        {
            products.Type = AggregationType.ByCategory;

            Remix.Server server = new Remix.Server("", "");
            Remix.Products remixProducts = server.GetProduct(category, products.CurrentPage);

            List<string> relatedSkuList = new List<string>();
            if (remixProducts != null && remixProducts.Count > 0)
            {
                int.TryParse(remixProducts.TotalPages, out products.TotalPages);
                int.TryParse(remixProducts.Total, out products.Total);
                int.TryParse(remixProducts.To, out products.To);
                int.TryParse(remixProducts.From, out products.From);
                int.TryParse(remixProducts.CurrentPage, out products.CurrentPage);

                foreach (var remixProduct in remixProducts)
                {
                    Product product = new Product();
                    product.BBYSKU = remixProduct.Sku;
                    product.UPC = remixProduct.UPC;
                    product.Name = remixProduct.Name;
                    product.BBYCategoryPath = remixProduct.CategoryPath.ToArray();
                    product.ThumbnailImageUrl = string.IsNullOrEmpty(remixProduct.ImageUrl) ?
                        remixProduct.ThumbnailimageUrl : remixProduct.ImageUrl;
                    product.LargeImageUrl = remixProduct.LargeImageUrl;
                    product.BBYUrl = remixProduct.BBYUrl;

                    product.BBYSubClassId = remixProduct.SubclassId;
                    product.BBYSubClassName = remixProduct.Subclass;

                    product.DescShort = remixProduct.ShortDescription;
                    decimal.TryParse(remixProduct.SalePrice, out product.BBYSalePrice);

                    if (remixProduct.RelatedProducts != null)
                    {
                        foreach (var sku in remixProduct.RelatedProducts)
                        {
                            product.SimilarProducts.Add(new Product() { BBYSKU = sku });
                            relatedSkuList.Add(sku);
                        }
                    }

                    products.Add(product);
                }
            }

            //
        }