private void GetASINData(IEnumerable <Entry> entries) { Queue <Entry> pendingList = new Queue <Entry>(entries); while (pendingList.Count > 0) { List <string> idList = new List <string>(); for (int i = 0; i < 5; i++) { if (pendingList.Count > 0) { idList.Add(pendingList.Dequeue().UPC); } } if (idList.Count > 0) { GetMatchingProductForIdRequest request = new GetMatchingProductForIdRequest(); request.SellerId = _marketplace.MerchantId; request.MarketplaceId = _marketplace.MarketplaceId; request.IdList = new IdListType(); request.IdList.Id = idList; request.IdType = "UPC"; while (_getMatchingProductQuota < 5) { Thread.Sleep(2000); } GetMatchingProductForIdResponse response = _marketplace.GetMWSProductsClient().GetMatchingProductForId(request); _getMatchingProductQuota = _getMatchingProductQuota - 5; if (response.IsSetGetMatchingProductForIdResult()) { foreach (GetMatchingProductForIdResult result in response.GetMatchingProductForIdResult) { if (result.status.Equals("Success") && result.IsSetProducts() && result.Products.IsSetProduct()) { Entry entry = entries.Where(p => p.UPC != null).Single(p => p.UPC.Equals(result.Id)); entry.ASIN = result.Products.Product.First().Identifiers.MarketplaceASIN.ASIN; } } } } } }
public GetMatchingProductForIdResponse InvokeGetMatchingProductForId(string sellerId, string mwsAuthToken, string marketplaceId, string idType, out APIResults results) { try { // Create a request. GetMatchingProductForIdRequest request = new GetMatchingProductForIdRequest(); request.SellerId = sellerId; request.MWSAuthToken = mwsAuthToken; request.MarketplaceId = marketplaceId; request.IdType = idType; IdListType idList = new IdListType(); request.IdList = idList; GetMatchingProductForIdResponse output = this.productClient.GetMatchingProductForId(request); results = new APIResults((IMWSResponse)output); return(output); } catch (MarketplaceWebServiceProductsException ex) { results = new APIResults(ex); throw ex; } }
/// <summary> /// GetMatchingProduct will return the details (attributes) for the /// given Identifier list. Identifer type can be one of [SKU|ASIN|UPC|EAN|ISBN|GTIN|JAN] /// /// </summary> /// <param name="service">Instance of MarketplaceWebServiceProducts service</param> /// <param name="request">GetMatchingProductForIdRequest request</param> public static void InvokeGetMatchingProductForId(MarketplaceWebServiceProducts service, GetMatchingProductForIdRequest request) { try { GetMatchingProductForIdResponse response = service.GetMatchingProductForId(request); Console.WriteLine("Service Response"); Console.WriteLine("============================================================================="); Console.WriteLine(); Console.WriteLine(" GetMatchingProductForIdResponse"); List <GetMatchingProductForIdResult> getMatchingProductForIdResultList = response.GetMatchingProductForIdResult; foreach (GetMatchingProductForIdResult getMatchingProductForIdResult in getMatchingProductForIdResultList) { Console.WriteLine(" GetMatchingProductForIdResult"); if (getMatchingProductForIdResult.IsSetId()) { Console.WriteLine(" Id"); Console.WriteLine(); Console.WriteLine(" {0}", getMatchingProductForIdResult.Id); Console.WriteLine(); } if (getMatchingProductForIdResult.IsSetIdType()) { Console.WriteLine(" IdType"); Console.WriteLine(); Console.WriteLine(" {0}", getMatchingProductForIdResult.IdType); Console.WriteLine(); } if (getMatchingProductForIdResult.IsSetstatus()) { Console.WriteLine(" status"); Console.WriteLine(); Console.WriteLine(" {0}", getMatchingProductForIdResult.status); Console.WriteLine(); } if (getMatchingProductForIdResult.IsSetProducts()) { Console.WriteLine(" Products"); ProductList products = getMatchingProductForIdResult.Products; List <Product> productList = products.Product; foreach (Product product in productList) { Console.WriteLine(" Product"); if (product.IsSetIdentifiers()) { Console.WriteLine(" Identifiers"); IdentifierType identifiers = product.Identifiers; if (identifiers.IsSetMarketplaceASIN()) { Console.WriteLine(" MarketplaceASIN"); ASINIdentifier marketplaceASIN = identifiers.MarketplaceASIN; if (marketplaceASIN.IsSetMarketplaceId()) { Console.WriteLine(" MarketplaceId"); Console.WriteLine(" {0}", marketplaceASIN.MarketplaceId); } if (marketplaceASIN.IsSetASIN()) { Console.WriteLine(" ASIN"); Console.WriteLine(" {0}", marketplaceASIN.ASIN); } } if (identifiers.IsSetSKUIdentifier()) { Console.WriteLine(" SKUIdentifier"); SellerSKUIdentifier SKUIdentifier = identifiers.SKUIdentifier; if (SKUIdentifier.IsSetMarketplaceId()) { Console.WriteLine(" MarketplaceId"); Console.WriteLine(" {0}", SKUIdentifier.MarketplaceId); } if (SKUIdentifier.IsSetSellerId()) { Console.WriteLine(" SellerId"); Console.WriteLine(" {0}", SKUIdentifier.SellerId); } if (SKUIdentifier.IsSetSellerSKU()) { Console.WriteLine(" SellerSKU"); Console.WriteLine(" {0}", SKUIdentifier.SellerSKU); } } } if (product.IsSetAttributeSets()) { Console.WriteLine(" Attributes"); foreach (var attribute in product.AttributeSets.Any) { Console.WriteLine(ProductsUtil.FormatXml((System.Xml.XmlElement)attribute)); } } if (product.IsSetRelationships()) { Console.WriteLine(string.Empty); Console.WriteLine(" Relationships"); foreach (var relationship in product.Relationships.Any) { Console.WriteLine(ProductsUtil.FormatXml((System.Xml.XmlElement)relationship)); } } if (product.IsSetCompetitivePricing()) { Console.WriteLine(" CompetitivePricing"); CompetitivePricingType competitivePricing = product.CompetitivePricing; if (competitivePricing.IsSetCompetitivePrices()) { Console.WriteLine(" CompetitivePrices"); CompetitivePriceList competitivePrices = competitivePricing.CompetitivePrices; List <CompetitivePriceType> competitivePriceList = competitivePrices.CompetitivePrice; foreach (CompetitivePriceType competitivePrice in competitivePriceList) { Console.WriteLine(" CompetitivePrice"); if (competitivePrice.IsSetcondition()) { Console.WriteLine(" condition"); Console.WriteLine(); Console.WriteLine(" {0}", competitivePrice.condition); Console.WriteLine(); } if (competitivePrice.IsSetsubcondition()) { Console.WriteLine(" subcondition"); Console.WriteLine(); Console.WriteLine(" {0}", competitivePrice.subcondition); Console.WriteLine(); } if (competitivePrice.IsSetbelongsToRequester()) { Console.WriteLine(" belongsToRequester"); Console.WriteLine(); Console.WriteLine(" {0}", competitivePrice.belongsToRequester); Console.WriteLine(); } if (competitivePrice.IsSetCompetitivePriceId()) { Console.WriteLine(" CompetitivePriceId"); Console.WriteLine(" {0}", competitivePrice.CompetitivePriceId); } if (competitivePrice.IsSetPrice()) { Console.WriteLine(" Price"); PriceType price = competitivePrice.Price; if (price.IsSetLandedPrice()) { Console.WriteLine(" LandedPrice"); MoneyType landedPrice = price.LandedPrice; if (landedPrice.IsSetCurrencyCode()) { Console.WriteLine(" CurrencyCode"); Console.WriteLine(" {0}", landedPrice.CurrencyCode); } if (landedPrice.IsSetAmount()) { Console.WriteLine(" Amount"); Console.WriteLine(" {0}", landedPrice.Amount); } } if (price.IsSetListingPrice()) { Console.WriteLine(" ListingPrice"); MoneyType listingPrice = price.ListingPrice; if (listingPrice.IsSetCurrencyCode()) { Console.WriteLine(" CurrencyCode"); Console.WriteLine(" {0}", listingPrice.CurrencyCode); } if (listingPrice.IsSetAmount()) { Console.WriteLine(" Amount"); Console.WriteLine(" {0}", listingPrice.Amount); } } if (price.IsSetShipping()) { Console.WriteLine(" Shipping"); MoneyType shipping = price.Shipping; if (shipping.IsSetCurrencyCode()) { Console.WriteLine(" CurrencyCode"); Console.WriteLine(" {0}", shipping.CurrencyCode); } if (shipping.IsSetAmount()) { Console.WriteLine(" Amount"); Console.WriteLine(" {0}", shipping.Amount); } } } } } if (competitivePricing.IsSetNumberOfOfferListings()) { Console.WriteLine(" NumberOfOfferListings"); NumberOfOfferListingsList numberOfOfferListings = competitivePricing.NumberOfOfferListings; List <OfferListingCountType> offerListingCountList = numberOfOfferListings.OfferListingCount; foreach (OfferListingCountType offerListingCount in offerListingCountList) { Console.WriteLine(" OfferListingCount"); if (offerListingCount.IsSetcondition()) { Console.WriteLine(" condition"); Console.WriteLine(); Console.WriteLine(" {0}", offerListingCount.condition); Console.WriteLine(); } if (offerListingCount.IsSetValue()) { Console.WriteLine(" Value"); Console.WriteLine(); Console.WriteLine(" {0}", offerListingCount.Value); } } } if (competitivePricing.IsSetTradeInValue()) { Console.WriteLine(" TradeInValue"); MoneyType tradeInValue = competitivePricing.TradeInValue; if (tradeInValue.IsSetCurrencyCode()) { Console.WriteLine(" CurrencyCode"); Console.WriteLine(" {0}", tradeInValue.CurrencyCode); } if (tradeInValue.IsSetAmount()) { Console.WriteLine(" Amount"); Console.WriteLine(" {0}", tradeInValue.Amount); } } } if (product.IsSetSalesRankings()) { Console.WriteLine(" SalesRankings"); SalesRankList salesRankings = product.SalesRankings; List <SalesRankType> salesRankList = salesRankings.SalesRank; foreach (SalesRankType salesRank in salesRankList) { Console.WriteLine(" SalesRank"); if (salesRank.IsSetProductCategoryId()) { Console.WriteLine(" ProductCategoryId"); Console.WriteLine(" {0}", salesRank.ProductCategoryId); } if (salesRank.IsSetRank()) { Console.WriteLine(" Rank"); Console.WriteLine(" {0}", salesRank.Rank); } } } if (product.IsSetLowestOfferListings()) { Console.WriteLine(" LowestOfferListings"); LowestOfferListingList lowestOfferListings = product.LowestOfferListings; List <LowestOfferListingType> lowestOfferListingList = lowestOfferListings.LowestOfferListing; foreach (LowestOfferListingType lowestOfferListing in lowestOfferListingList) { Console.WriteLine(" LowestOfferListing"); if (lowestOfferListing.IsSetQualifiers()) { Console.WriteLine(" Qualifiers"); QualifiersType qualifiers = lowestOfferListing.Qualifiers; if (qualifiers.IsSetItemCondition()) { Console.WriteLine(" ItemCondition"); Console.WriteLine(" {0}", qualifiers.ItemCondition); } if (qualifiers.IsSetItemSubcondition()) { Console.WriteLine(" ItemSubcondition"); Console.WriteLine(" {0}", qualifiers.ItemSubcondition); } if (qualifiers.IsSetFulfillmentChannel()) { Console.WriteLine(" FulfillmentChannel"); Console.WriteLine(" {0}", qualifiers.FulfillmentChannel); } if (qualifiers.IsSetShipsDomestically()) { Console.WriteLine(" ShipsDomestically"); Console.WriteLine(" {0}", qualifiers.ShipsDomestically); } if (qualifiers.IsSetShippingTime()) { Console.WriteLine(" ShippingTime"); ShippingTimeType shippingTime = qualifiers.ShippingTime; if (shippingTime.IsSetMax()) { Console.WriteLine(" Max"); Console.WriteLine(" {0}", shippingTime.Max); } } if (qualifiers.IsSetSellerPositiveFeedbackRating()) { Console.WriteLine(" SellerPositiveFeedbackRating"); Console.WriteLine(" {0}", qualifiers.SellerPositiveFeedbackRating); } } if (lowestOfferListing.IsSetNumberOfOfferListingsConsidered()) { Console.WriteLine(" NumberOfOfferListingsConsidered"); Console.WriteLine(" {0}", lowestOfferListing.NumberOfOfferListingsConsidered); } if (lowestOfferListing.IsSetSellerFeedbackCount()) { Console.WriteLine(" SellerFeedbackCount"); Console.WriteLine(" {0}", lowestOfferListing.SellerFeedbackCount); } if (lowestOfferListing.IsSetPrice()) { Console.WriteLine(" Price"); PriceType price1 = lowestOfferListing.Price; if (price1.IsSetLandedPrice()) { Console.WriteLine(" LandedPrice"); MoneyType landedPrice1 = price1.LandedPrice; if (landedPrice1.IsSetCurrencyCode()) { Console.WriteLine(" CurrencyCode"); Console.WriteLine(" {0}", landedPrice1.CurrencyCode); } if (landedPrice1.IsSetAmount()) { Console.WriteLine(" Amount"); Console.WriteLine(" {0}", landedPrice1.Amount); } } if (price1.IsSetListingPrice()) { Console.WriteLine(" ListingPrice"); MoneyType listingPrice1 = price1.ListingPrice; if (listingPrice1.IsSetCurrencyCode()) { Console.WriteLine(" CurrencyCode"); Console.WriteLine(" {0}", listingPrice1.CurrencyCode); } if (listingPrice1.IsSetAmount()) { Console.WriteLine(" Amount"); Console.WriteLine(" {0}", listingPrice1.Amount); } } if (price1.IsSetShipping()) { Console.WriteLine(" Shipping"); MoneyType shipping1 = price1.Shipping; if (shipping1.IsSetCurrencyCode()) { Console.WriteLine(" CurrencyCode"); Console.WriteLine(" {0}", shipping1.CurrencyCode); } if (shipping1.IsSetAmount()) { Console.WriteLine(" Amount"); Console.WriteLine(" {0}", shipping1.Amount); } } } if (lowestOfferListing.IsSetMultipleOffersAtLowestPrice()) { Console.WriteLine(" MultipleOffersAtLowestPrice"); Console.WriteLine(" {0}", lowestOfferListing.MultipleOffersAtLowestPrice); } } } if (product.IsSetOffers()) { Console.WriteLine(" Offers"); OffersList offers = product.Offers; List <OfferType> offerList = offers.Offer; foreach (OfferType offer in offerList) { Console.WriteLine(" Offer"); if (offer.IsSetBuyingPrice()) { Console.WriteLine(" BuyingPrice"); PriceType buyingPrice = offer.BuyingPrice; if (buyingPrice.IsSetLandedPrice()) { Console.WriteLine(" LandedPrice"); MoneyType landedPrice2 = buyingPrice.LandedPrice; if (landedPrice2.IsSetCurrencyCode()) { Console.WriteLine(" CurrencyCode"); Console.WriteLine(" {0}", landedPrice2.CurrencyCode); } if (landedPrice2.IsSetAmount()) { Console.WriteLine(" Amount"); Console.WriteLine(" {0}", landedPrice2.Amount); } } if (buyingPrice.IsSetListingPrice()) { Console.WriteLine(" ListingPrice"); MoneyType listingPrice2 = buyingPrice.ListingPrice; if (listingPrice2.IsSetCurrencyCode()) { Console.WriteLine(" CurrencyCode"); Console.WriteLine(" {0}", listingPrice2.CurrencyCode); } if (listingPrice2.IsSetAmount()) { Console.WriteLine(" Amount"); Console.WriteLine(" {0}", listingPrice2.Amount); } } if (buyingPrice.IsSetShipping()) { Console.WriteLine(" Shipping"); MoneyType shipping2 = buyingPrice.Shipping; if (shipping2.IsSetCurrencyCode()) { Console.WriteLine(" CurrencyCode"); Console.WriteLine(" {0}", shipping2.CurrencyCode); } if (shipping2.IsSetAmount()) { Console.WriteLine(" Amount"); Console.WriteLine(" {0}", shipping2.Amount); } } } if (offer.IsSetRegularPrice()) { Console.WriteLine(" RegularPrice"); MoneyType regularPrice = offer.RegularPrice; if (regularPrice.IsSetCurrencyCode()) { Console.WriteLine(" CurrencyCode"); Console.WriteLine(" {0}", regularPrice.CurrencyCode); } if (regularPrice.IsSetAmount()) { Console.WriteLine(" Amount"); Console.WriteLine(" {0}", regularPrice.Amount); } } if (offer.IsSetFulfillmentChannel()) { Console.WriteLine(" FulfillmentChannel"); Console.WriteLine(" {0}", offer.FulfillmentChannel); } if (offer.IsSetItemCondition()) { Console.WriteLine(" ItemCondition"); Console.WriteLine(" {0}", offer.ItemCondition); } if (offer.IsSetItemSubCondition()) { Console.WriteLine(" ItemSubCondition"); Console.WriteLine(" {0}", offer.ItemSubCondition); } if (offer.IsSetSellerId()) { Console.WriteLine(" SellerId"); Console.WriteLine(" {0}", offer.SellerId); } if (offer.IsSetSellerSKU()) { Console.WriteLine(" SellerSKU"); Console.WriteLine(" {0}", offer.SellerSKU); } } } } } if (getMatchingProductForIdResult.IsSetError()) { Console.WriteLine(" Error"); Error error = getMatchingProductForIdResult.Error; if (error.IsSetType()) { Console.WriteLine(" Type"); Console.WriteLine(" {0}", error.Type); } if (error.IsSetCode()) { Console.WriteLine(" Code"); Console.WriteLine(" {0}", error.Code); } if (error.IsSetMessage()) { Console.WriteLine(" Message"); Console.WriteLine(" {0}", error.Message); } } } if (response.IsSetResponseMetadata()) { Console.WriteLine(" ResponseMetadata"); ResponseMetadata responseMetadata = response.ResponseMetadata; if (responseMetadata.IsSetRequestId()) { Console.WriteLine(" RequestId"); Console.WriteLine(" {0}", responseMetadata.RequestId); } } Console.WriteLine(" ResponseHeaderMetadata"); Console.WriteLine(" RequestId"); Console.WriteLine(" " + response.ResponseHeaderMetadata.RequestId); Console.WriteLine(" ResponseContext"); Console.WriteLine(" " + response.ResponseHeaderMetadata.ResponseContext); Console.WriteLine(" Timestamp"); Console.WriteLine(" " + response.ResponseHeaderMetadata.Timestamp); Console.WriteLine(); } catch (MarketplaceWebServiceProductsException ex) { Console.WriteLine("Caught Exception: " + ex.Message); Console.WriteLine("Response Status Code: " + ex.StatusCode); Console.WriteLine("Error Code: " + ex.ErrorCode); Console.WriteLine("Error Type: " + ex.ErrorType); Console.WriteLine("Request ID: " + ex.RequestId); Console.WriteLine("XML: " + ex.XML); Console.WriteLine("ResponseHeaderMetadata: " + ex.ResponseHeaderMetadata); } }
public static void InvokeGetMatchingProductForId(MarketplaceWebServiceProducts service, GetMatchingProductForIdRequest request) { try{ GetMatchingProductForIdResponse response = service.GetMatchingProductForId(request); List <GetMatchingProductForIdResult> getMatchingProductForIdResultList = response.GetMatchingProductForIdResult; foreach ( GetMatchingProductForIdResult getMatchingProductForIdResult in getMatchingProductForIdResultList) { ProductList products = getMatchingProductForIdResult.Products; List <Product> productList = products.Product; foreach (Product product in productList) { if (getMatchingProductForIdResult.IsSetProducts()) { if (product.IsSetAttributeSets()) { //Binding, Format, ASIN, Height, Length, Width, Weight, Product Group, Small Image URL, Title, Sales Rank foreach (var attribute in product.AttributeSets.Any) { string xml = ProductsUtil.FormatXml((System.Xml.XmlElement)attribute); XElement element = XElement.Parse(xml); XNamespace ns2 = "http://mws.amazonservices.com/schema/Products/2011-10-01/default.xsd"; title = element.Element(ns2 + "Title").Value; binding = element.Element(ns2 + "Binding").Value; productGroup = element.Element(ns2 + "ProductGroup").Value; smallImageUrl = element.Element(ns2 + "SmallImage").Element(ns2 + "URL").Value; height = element.Element(ns2 + "ItemDimensions").Element(ns2 + "Height").Value; length = element.Element(ns2 + "ItemDimensions").Element(ns2 + "Length").Value; width = element.Element(ns2 + "ItemDimensions").Element(ns2 + "Width").Value; weight = element.Element(ns2 + "ItemDimensions").Element(ns2 + "Weight").Value; } } if (product.IsSetIdentifiers()) { IdentifierType identifier = product.Identifiers; if (identifier.IsSetMarketplaceASIN()) { ASINIdentifier marketplaceASIN = identifier.MarketplaceASIN; if (marketplaceASIN.IsSetASIN()) { ASIN = marketplaceASIN.ASIN; } } } if (product.IsSetSalesRankings()) { int i = 0; SalesRankList rankings = product.SalesRankings; List <SalesRankType> salesRankList = rankings.SalesRank; foreach (SalesRankType saleRankings in salesRankList) { for (; i < 1; i++) { if (saleRankings.IsSetRank()) { salesRank = Convert.ToString(saleRankings.Rank); } } } } Console.WriteLine("Height: {0} \nLength: {1} \nWidth: {2} " + "\nWeight: {3} \nBinding: {4} \nProduct Group: {5} " + "\nURL: {6} \nTitle: {7} \nASIN: {8} \nSale Rank: {9} \n", height, length, width, weight, binding, productGroup, smallImageUrl, title, ASIN, salesRank); } } } } catch (MarketplaceWebServiceProductsException ex) { Console.WriteLine("Caught Exception: " + ex.Message); Console.WriteLine("Response Status Code: " + ex.StatusCode); Console.WriteLine("Error Code: " + ex.ErrorCode); Console.WriteLine("Error Type: " + ex.ErrorType); Console.WriteLine("Request ID: " + ex.RequestId); Console.WriteLine("XML: " + ex.XML); Console.WriteLine("ResponseHeaderMetadata: " + ex.ResponseHeaderMetadata); } }
private ProductAmazon parsedToMarketplaceProduct(GetMatchingProductForIdResponse response) { var xmlDoc = new XmlDocument(); var matchProductResult = response.GetMatchingProductForIdResult.First(); var nsmgr = new XmlNamespaceManager(xmlDoc.NameTable); nsmgr.AddNamespace("ns", "http://mws.amazonservices.com/schema/Products/2011-10-01"); nsmgr.AddNamespace("ns2", "http://mws.amazonservices.com/schema/Products/2011-10-01/default.xsd"); if (matchProductResult.status != "Success") { _logger.LogWarning(LogEntryType.AmazonProduct, string.Format("GetMatchingProductForIdResponse was unsuccessful! - Id Type: {0} - {1}", matchProductResult.IdType, matchProductResult.Id)); return(null); } xmlDoc.LoadXml(matchProductResult.ToXML()); var rowNode = xmlDoc.ChildNodes[0]; var productAttrNode = rowNode.SelectSingleNode("//ns:Products/ns:Product/ns:AttributeSets/ns2:ItemAttributes", nsmgr); var featureNodes = rowNode.SelectNodes("//ns:Products/ns:Product/ns:AttributeSets/ns2:ItemAttributes/ns2:Feature", nsmgr); var smallImageNodes = rowNode.SelectNodes("//ns:Products/ns:Product/ns:AttributeSets/ns2:ItemAttributes/ns2:SmallImage", nsmgr); var binding = productAttrNode["ns2:Binding"] == null ? "0" : productAttrNode["ns2:Binding"].InnerText; var brand = productAttrNode["ns2:Brand"] == null ? "0" : productAttrNode["ns2:Brand"].InnerText; var color = productAttrNode["ns2:Color"] == null ? string.Empty : productAttrNode["ns2:Color"].InnerText; var department = productAttrNode["ns2:Department"] == null ? "0" : productAttrNode["ns2:Department"].InnerText; var gemType = productAttrNode["ns2:GemType"] == null ? "0" : productAttrNode["ns2:GemType"].InnerText; var label = productAttrNode["ns2:Label"] == null ? "0" : productAttrNode["ns2:Label"].InnerText; var manufacturer = productAttrNode["ns2:Manufacturer"] == null ? string.Empty : productAttrNode["ns2:Manufacturer"].InnerText; var metypeType = productAttrNode["ns2:MetalType"] == null ? "0" : productAttrNode["ns2:MetalType"].InnerText; var model = productAttrNode["ns2:Model"] == null ? string.Empty : productAttrNode["ns2:Model"].InnerText; var numOfItems = productAttrNode["ns2:NumberOfItems"] == null ? "0" : productAttrNode["ns2:NumberOfItems"].InnerText; var packageQty = productAttrNode["ns2:PackageQuantity"] == null ? "0" : productAttrNode["ns2:PackageQuantity"].InnerText; var partNumber = productAttrNode["ns2:PartNumber"] == null ? string.Empty : productAttrNode["ns2:PartNumber"].InnerText; var productGroup = productAttrNode["ns2:ProductGroup"] == null ? string.Empty : productAttrNode["ns2:ProductGroup"].InnerText; var productTypeName = productAttrNode["ns2:ProductTypeName"] == null ? string.Empty : productAttrNode["ns2:ProductTypeName"].InnerText; var publisher = productAttrNode["ns2:Publisher"] == null ? string.Empty : productAttrNode["ns2:Publisher"].InnerText; var title = productAttrNode["ns2:Title"] == null ? string.Empty : productAttrNode["ns2:Title"].InnerText; // get the product's features var features = new List <string>(); foreach (XmlNode node in featureNodes) { features.Add(node.InnerText); } // parse the product's images var smallImageUrls = new List <MediaContent>(); foreach (XmlNode node in smallImageNodes) { var imageNode = node["ns2:URL"]; smallImageUrls.Add(new MediaContent { Url = imageNode == null ? string.Empty : imageNode.InnerText, Caption = ChannelName, }); } var eProduct = new ProductAmazon { EisSKU = matchProductResult.Id, ProductTitle = title, NumOfItems = Convert.ToInt16(numOfItems), PackageQty = Convert.ToInt16(packageQty), ASIN = matchProductResult.Products.Product.First().Identifiers.MarketplaceASIN.ASIN, Brand = brand, Manufacturer = manufacturer, Model = model, ProductGroup = productGroup, ProductTypeName = productTypeName, Features = features, Images = smallImageUrls, }; // get the list price for MAP price var listPriceNode = productAttrNode["ns2:ListPrice"]; if (listPriceNode != null) { var amountNode = listPriceNode["ns2:Height"]; eProduct.MapPrice = amountNode == null ? 0 : Convert.ToDecimal(amountNode.InnerText); } // get the eisProduct dimension var itemDimensionNode = productAttrNode["ns2:ItemDimensions"]; if (itemDimensionNode != null) { var heightNode = itemDimensionNode["ns2:Height"]; var height = new Measurement(); if (heightNode != null) { height.Value = Convert.ToDecimal(heightNode.InnerText); height.Unit = heightNode.Attributes["Units"].Value; } var lengthNode = itemDimensionNode["ns2:Length"]; var length = new Measurement(); if (lengthNode != null) { length.Value = Convert.ToDecimal(lengthNode.InnerText); length.Unit = lengthNode.Attributes["Units"].Value; } var widthhNode = itemDimensionNode["ns2:Width"]; var width = new Measurement(); if (widthhNode != null) { width.Value = Convert.ToDecimal(widthhNode.InnerText); width.Unit = widthhNode.Attributes["Units"].Value; } var weightNode = itemDimensionNode["ns2:Weight"]; var weight = new Measurement(); if (weightNode != null) { weight.Value = Convert.ToDecimal(weightNode.InnerText); weight.Unit = weightNode.Attributes["Units"].Value; } eProduct.ItemDimension = new Dimension(length, width, height, weight); } // get the eisProduct's package dimension var packageDimensionNode = productAttrNode["ns2:PackageDimensions"]; if (packageDimensionNode != null) { var heightNode = packageDimensionNode["ns2:Height"]; var height = new Measurement(); if (heightNode != null) { height.Value = Convert.ToDecimal(heightNode.InnerText); height.Unit = heightNode.Attributes["Units"].Value; } var lengthNode = packageDimensionNode["ns2:Length"]; var length = new Measurement(); if (lengthNode != null) { length.Value = Convert.ToDecimal(lengthNode.InnerText); length.Unit = lengthNode.Attributes["Units"].Value; } var widthhNode = packageDimensionNode["ns2:Width"]; var width = new Measurement(); if (widthhNode != null) { width.Value = Convert.ToDecimal(widthhNode.InnerText); width.Unit = widthhNode.Attributes["Units"].Value; } var weightNode = packageDimensionNode["ns2:Weight"]; var weight = new Measurement(); if (weightNode != null) { weight.Value = Convert.ToDecimal(weightNode.InnerText); weight.Unit = weightNode.Attributes["Units"].Value; } eProduct.PackageDimension = new Dimension(length, width, height, weight); } return(eProduct); }