/// <summary> /// Initializes a new instance of the <see cref="WishListItemBaseJsonResult" /> class. /// </summary> /// <param name="line">The line.</param> /// <param name="wishListId">The wish list identifier.</param> public WishListItemBaseJsonResult(WishListLine line, string wishListId) { Assert.ArgumentNotNull(line, "line"); Assert.ArgumentNotNullOrEmpty(wishListId, "wishListId"); var product = (CommerceCartProduct)line.Product; var productItem = Sitecore.Reference.Storefront.SitecorePipelines.ProductItemResolver.ResolveCatalogItem(product.ProductId, product.ProductCatalog, true); var currencyCode = StorefrontManager.GetCustomerCurrency(); this.DisplayName = product.DisplayName; this.Color = product.Properties["Color"] as string; this.LineDiscount = ((CommerceTotal)line.Total).LineItemDiscountAmount.ToString(Sitecore.Context.Language.CultureInfo); this.Quantity = line.Quantity.ToString(Sitecore.Context.Language.CultureInfo); this.LineTotal = line.Total.Amount.ToCurrency(currencyCode); this.ExternalLineId = line.ExternalId; this.ProductId = product.ProductId; this.VariantId = product.ProductVariantId; this.ProductCatalog = product.ProductCatalog; this.WishListId = wishListId; this.ProductUrl = product.ProductId.Equals(StorefrontManager.CurrentStorefront.GiftCardProductId, StringComparison.OrdinalIgnoreCase) ? StorefrontManager.StorefrontUri("/buygiftcard") : LinkManager.GetDynamicUrl(productItem); if (product.Price.Amount != 0M) { this.LinePrice = product.Price.Amount.ToCurrency(currencyCode); } var imageInfo = product.Properties["_product_Images"] as string; if (imageInfo != null) { var imageId = imageInfo.Split('|')[0]; MediaItem mediaItem = Sitecore.Context.Database.GetItem(imageId); this.Image = mediaItem.GetImageUrl(100, 100); } var giftCardAmount = line.GetPropertyValue("GiftCardAmount"); if (giftCardAmount != null) { decimal amount = System.Convert.ToDecimal(giftCardAmount, Sitecore.Context.Language.CultureInfo); this.GiftCardAmount = amount.ToCurrency(currencyCode); } }