public AmazonListing UpdateAmazonListing(AmazonListing amazonListing) { var productVariant = _productVariantService.GetProductVariantBySKU(amazonListing.ProductVariant.SKU); amazonListing.ProductVariant = productVariant; amazonListing.Brand = productVariant.Product.Brand != null ? productVariant.Product.Brand.Name : String.Empty; amazonListing.Condition = ConditionType.New; var currency = _ecommerceSettings.Currency(); amazonListing.Currency = (currency != null && !String.IsNullOrWhiteSpace(currency.Code))?currency.Code:CurrencyCode.GBP.GetDescription(); amazonListing.Manafacturer = productVariant.Product.Brand != null ? productVariant.Product.Brand.Name : String.Empty; amazonListing.MfrPartNumber = productVariant.ManufacturerPartNumber; amazonListing.Quantity = productVariant.TrackingPolicy == TrackingPolicy.Track ? _getStockRemainingQuantity.Get(productVariant) : 1000; amazonListing.Price = _productPricingMethod.GetUnitPrice(productVariant, 0m, 0m); amazonListing.SellerSKU = productVariant.SKU; amazonListing.Title = productVariant.DisplayName; amazonListing.StandardProductIDType = _amazonSellerSettings.BarcodeIsOfType; amazonListing.StandardProductId = productVariant.Barcode.Trim(); amazonListing.FulfillmentChannel = amazonListing.AmazonListingGroup.FulfillmentChannel ?? AmazonFulfillmentChannel.MFN; _amazonListingService.Save(amazonListing); return(amazonListing); }
public bool IsInStock(ProductVariant productVariant) { if (productVariant.TrackingPolicy == TrackingPolicy.DontTrack) { return(true); } return(_getStockRemainingQuantity.Get(productVariant) > 0); }
public byte[] GetFile(IEnumerable <ProductVariant> variants) { return(_csvFileWriter.GetFile(variants.Where(variant => variant.Product.Published), new Dictionary <string, Func <ProductVariant, object> > { { "Name", variant => variant.FullName }, { "SKU", variant => variant.SKU }, { "Stock Remaining", variant => _getStockRemainingQuantity.Get(variant) } })); }
private static void AddVariantInfo(int i, ExcelWorksheet wsItems, IList <ProductVariant> productVariants, int rowId, IGetStockRemainingQuantity getStockRemainingQuantity) { wsItems.Cells["K" + rowId].Value = productVariants[i].Name ?? String.Empty; wsItems.Cells["L" + rowId].Value = productVariants[i].BasePrice; wsItems.Cells["M" + rowId].Value = productVariants[i].PreviousPrice; if (productVariants[i].TaxRate != null) { wsItems.Cells["N" + rowId].Value = productVariants[i].TaxRate.Id; } wsItems.Cells["O" + rowId].Value = productVariants[i].Weight; wsItems.Cells["P" + rowId].Value = getStockRemainingQuantity.Get(productVariants[i]); wsItems.Cells["Q" + rowId].Value = productVariants[i].TrackingPolicy; wsItems.Cells["R" + rowId].Value = productVariants[i].SKU; wsItems.Cells["S" + rowId].Value = productVariants[i].Barcode; wsItems.Cells["T" + rowId].Value = productVariants[i].ManufacturerPartNumber; wsItems.Cells["AG" + rowId].Value = (productVariants[i].ETag != null) ? productVariants[i].ETag.Name : String.Empty; }
private static void AddVariantInfo(int i, ExcelWorksheet wsItems, IList<ProductVariant> productVariants, int rowId, IGetStockRemainingQuantity getStockRemainingQuantity) { wsItems.Cells["K" + rowId].Value = productVariants[i].Name ?? String.Empty; wsItems.Cells["L" + rowId].Value = productVariants[i].BasePrice; wsItems.Cells["M" + rowId].Value = productVariants[i].PreviousPrice; if (productVariants[i].TaxRate != null) wsItems.Cells["N" + rowId].Value = productVariants[i].TaxRate.Id; wsItems.Cells["O" + rowId].Value = productVariants[i].Weight; wsItems.Cells["P" + rowId].Value = getStockRemainingQuantity.Get(productVariants[i]); wsItems.Cells["Q" + rowId].Value = productVariants[i].TrackingPolicy; wsItems.Cells["R" + rowId].Value = productVariants[i].SKU; wsItems.Cells["S" + rowId].Value = productVariants[i].Barcode; wsItems.Cells["T" + rowId].Value = productVariants[i].ManufacturerPartNumber; wsItems.Cells["AG" + rowId].Value = (productVariants[i].ETag != null) ? productVariants[i].ETag.Name : String.Empty; }
/// <summary> /// Export Google BaseProduct /// </summary> /// <param name="xml"></param> /// <param name="productVariant"></param> /// <param name="ns"></param> private void ExportGoogleBaseProduct(ref XmlTextWriter xml, ProductVariant productVariant, string ns) { xml.WriteStartElement("item"); //TITLE string title = String.Empty; if (!String.IsNullOrWhiteSpace(productVariant.DisplayName)) { title = productVariant.DisplayName; } if (title.Length > 70) { title = title.Substring(0, 70); } xml.WriteElementString("title", title); //LINK if (productVariant.Product != null && !String.IsNullOrWhiteSpace(productVariant.DisplayName)) { xml.WriteElementString("link", GeneralHelper.GetValidProductVariantUrl(productVariant)); } //DESCRIPTION xml.WriteStartElement("description"); string description = String.Empty; if (productVariant.Product != null && !String.IsNullOrWhiteSpace(productVariant.DisplayName)) { description = productVariant.Product.BodyContent.StripHtml(); } if (productVariant.Product != null && String.IsNullOrEmpty(description)) { description = productVariant.Product.ProductAbstract.StripHtml(); } if (productVariant.Product != null && String.IsNullOrEmpty(description)) { description = productVariant.DisplayName.StripHtml(); } description = XmlCharacterWhitelist(description); byte[] descriptionBytes = Encoding.Default.GetBytes(description); description = Encoding.UTF8.GetString(descriptionBytes); xml.WriteCData(description); xml.WriteEndElement(); GoogleBaseProduct googleBaseProduct = productVariant.GoogleBaseProducts.FirstOrDefault(); //CONDITION xml.WriteElementString("g", "condition", ns, googleBaseProduct != null ? googleBaseProduct.Condition.ToString() : ProductCondition.New.ToString()); //PRICE xml.WriteElementString("g", "price", ns, productVariant.Price.ToCurrencyFormat()); //AVAILABILITY string availability = "In Stock"; if (productVariant.TrackingPolicy == TrackingPolicy.Track && _getStockRemainingQuantity.Get(productVariant) <= 0) { availability = "Out of Stock"; } xml.WriteElementString("g", "availability", ns, availability); //GOOGLE PRODUCT CATEGORY if (googleBaseProduct != null) { xml.WriteElementString("g", "google_product_category", ns, googleBaseProduct.Category); } //PRODUCT CATEGORY if (productVariant.Product != null && productVariant.Product.Categories.Any() && !String.IsNullOrWhiteSpace(productVariant.Product.Categories.First().Name)) { xml.WriteElementString("g", "product_type", ns, productVariant.Product.Categories.First().Name); } else if (googleBaseProduct != null) { xml.WriteElementString("g", "product_type", ns, googleBaseProduct.Category); } //IMAGES if (productVariant.Product != null && productVariant.Product.Images.Any() && !String.IsNullOrWhiteSpace(productVariant.Product.Images.First().FileUrl)) { xml.WriteElementString("g", "image_link", ns, GeneralHelper.GetValidImageUrl(productVariant.Product.Images.First().FileUrl)); } if (productVariant.Product != null && productVariant.Product.Images.Count() > 1 && !String.IsNullOrWhiteSpace(productVariant.Product.Images.ToList()[1].FileUrl)) { xml.WriteElementString("g", "additional_image_link", ns, GeneralHelper.GetValidImageUrl(productVariant.Product.Images.ToList()[1].FileUrl)); } //BRAND if (productVariant.Product != null && productVariant.Product.BrandPage != null && !String.IsNullOrWhiteSpace(productVariant.Product.BrandPage.Name)) { xml.WriteElementString("g", "brand", ns, productVariant.Product.BrandPage.Name); } //ID xml.WriteElementString("g", "id", ns, productVariant.Id.ToString(new CultureInfo("en-GB", false).NumberFormat)); //GTIN if (!String.IsNullOrWhiteSpace(productVariant.Barcode)) { xml.WriteElementString("g", "gtin", ns, productVariant.Barcode); } //MPN if (!String.IsNullOrWhiteSpace(productVariant.ManufacturerPartNumber)) { xml.WriteElementString("g", "mpn", ns, productVariant.ManufacturerPartNumber); } if (googleBaseProduct != null) { //GENDER xml.WriteElementString("g", "gender", ns, googleBaseProduct.Gender.ToString()); //AGE GROUP xml.WriteElementString("g", "age_group", ns, googleBaseProduct.AgeGroup.ToString()); } //ITEM GROUP ID if (productVariant.Product != null) { xml.WriteElementString("g", "item_group_id", ns, productVariant.Product.Id.ToString(new CultureInfo("en-GB", false).NumberFormat)); } if (googleBaseProduct != null) { //COLOR if (!String.IsNullOrWhiteSpace(googleBaseProduct.Color)) { xml.WriteElementString("g", "color", ns, googleBaseProduct.Color); } //SIZE if (!String.IsNullOrWhiteSpace(googleBaseProduct.Size)) { xml.WriteElementString("g", "size", ns, googleBaseProduct.Size); } //PATTERN if (!String.IsNullOrWhiteSpace(googleBaseProduct.Pattern)) { xml.WriteElementString("g", "pattern", ns, googleBaseProduct.Pattern); } //MATERIAL if (!String.IsNullOrWhiteSpace(googleBaseProduct.Material)) { xml.WriteElementString("g", "material", ns, googleBaseProduct.Material); } } //SHIPPING SetGoogleBaseShipping(ref xml, productVariant, ns); //WEIGHT xml.WriteElementString("g", "shipping_weight", ns, string.Format(CultureInfo.InvariantCulture, "{0} {1}", productVariant.Weight.ToString(new CultureInfo("en-GB", false).NumberFormat), "kg")); //ADWORDS if (googleBaseProduct != null) { if (!String.IsNullOrWhiteSpace(googleBaseProduct.Grouping)) { xml.WriteElementString("g", "adwords_grouping", ns, googleBaseProduct.Grouping); } if (!String.IsNullOrWhiteSpace(googleBaseProduct.Labels)) { xml.WriteElementString("g", "adwords_labels", ns, googleBaseProduct.Labels); } if (!String.IsNullOrWhiteSpace(googleBaseProduct.Redirect)) { xml.WriteElementString("g", "adwords_redirect", ns, googleBaseProduct.Redirect); } } xml.WriteEndElement(); }
public ProductStockCheckerBuilder StockRemaining(int remaining) { A.CallTo(() => _getStockRemainingQuantity.Get(A <ProductVariant> ._)).Returns(remaining); return(this); }