public override catalogProductCreateEntity CreateParentProductData(bsi_posts post, IEnumerable <string> childrenSkus) { int brandID = this.GetBrandID(post.bsi_posting.brand); int ebayCategoryID = this.GetEbayCategoryID(post.bsi_posting.category); catalogProductCreateEntity productData = new catalogProductCreateEntity(); productData.visibility = "4"; productData.stock_data = null; productData.additional_attributes = null; productData.name = post.title; productData.description = post.bsi_posting.fullDescription; productData.short_description = post.title; productData.price = post.price; productData.status = "1"; productData.websites = new string[1] { "base" }; productData.has_options = "1"; productData.categories = new string[2] { ebayCategoryID.ToString(), brandID.ToString() }; productData.associated_skus = childrenSkus.ToArray(); return(productData); }
public override bool IsMatch(bsi_posts post) { string gender = post.bsi_posting.gender.ToUpper().Trim(); if (gender.Equals("WOMENS") || gender.Equals("WOMEN")) { bsi_quantities postItem = post.bsi_quantities.First(); string formattedWidth = this.FormatWidth(postItem.width); if (_sizeAttributeOptions.Any(p => p.label.Equals(postItem.size)) && _widthAttributeOptions.Any(p => p.label.Equals(formattedWidth))) { return(true); } } return(false); }
private void AssignImages(bsi_posts post, string parentID) { //Upload associated images string index = ""; int count = 1; string imagePath = @"P:/products/" + post.bsi_posting.brand + @"/" + post.sku + ".jpg"; while (File.Exists(imagePath)) { catalogProductAttributeMediaCreateEntity media = UploadProductImage(imagePath, count, post.sku + index); _proxy.catalogProductAttributeMediaCreate(_sessionID, parentID.ToString(), media, null, "product ID"); count++; index = "-" + count.ToString(); imagePath = @"P:/products/" + post.bsi_posting.brand + @"/" + post.sku + index + ".jpg"; } }
private void CreateOrUpdateCatalogProduct(bsi_posts post) { CatalogProductFactory catalogProductFactory = _catalogProductFactories.SingleOrDefault(p => p.IsMatch(post)); if (catalogProductFactory == null) { throw new NotImplementedException("This type of product is currently not supported"); } List <string> childSkus = new List <string>(); foreach (bsi_quantities postItem in post.bsi_quantities) { string sku = postItem.itemLookupCode; catalogProductCreateEntity simpleProductData = catalogProductFactory.CreateProductData(post, postItem); try { int ID = _proxy.catalogProductCreate(_sessionID, "simple", catalogProductFactory.GetAttributeSet(), sku, simpleProductData, null); childSkus.Add(sku); } catch (Exception ex) { childSkus.Add(sku); if (!_proxy.catalogProductUpdate(_sessionID, sku, simpleProductData, null, "sku")) { this.Log(sku + ": " + ex.Message); } } } catalogProductCreateEntity configurableProductData = catalogProductFactory.CreateParentProductData(post, childSkus); try { int parentID = _proxy.catalogProductCreate(_sessionID, "configurable", catalogProductFactory.GetAttributeSet(), post.sku, configurableProductData, null); AssignImages(post, parentID.ToString()); } catch (Exception ex) { if (!_proxy.catalogProductUpdate(_sessionID, post.sku, configurableProductData, null, "sku")) { this.Log(post.sku + ": " + ex.Message); } } }
public override catalogProductCreateEntity CreateProductData(bsi_posts post, bsi_quantities postItem) { int brandID = this.GetBrandID(post.bsi_posting.brand); int ebayCategoryID = this.GetEbayCategoryID(post.bsi_posting.category); catalogProductCreateEntity productData = new catalogProductCreateEntity(); productData.visibility = "4"; productData.stock_data = null; productData.additional_attributes = null; productData.name = post.title; productData.description = post.bsi_posting.fullDescription; productData.short_description = post.title; productData.price = post.price; productData.status = "1"; productData.websites = new string[1] { "base" }; productData.has_options = "1"; productData.categories = new string[2] { ebayCategoryID.ToString(), brandID.ToString() }; productData.visibility = "1"; productData.stock_data = new catalogInventoryStockItemUpdateEntity(); productData.stock_data.is_in_stock = 1; productData.stock_data.is_in_stockSpecified = true; productData.price = post.price; productData.stock_data.qty = postItem.quantity.ToString(); productData.additional_attributes = new catalogProductAdditionalAttributesEntity(); productData.additional_attributes.single_data = new associativeEntity[2] { this.BuildSizeData(postItem.size), this.BuildWidthData(postItem.width) }; return(productData); }
public abstract bool IsMatch(bsi_posts post);
public abstract catalogProductCreateEntity CreateParentProductData(bsi_posts post, IEnumerable <string> childrenSkus);
public abstract catalogProductCreateEntity CreateProductData(bsi_posts post, bsi_quantities postItem);