Error executing template "Designs/identity_v2/ecom/productlist/partials/item.cshtml"
System.ArgumentException: An item with the same key has already been added.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at Co3.ID.Dw.Models.Frontend.Ecommerce.IdentityProduct.GetVariantCombinationsPrimaryImages() in C:\Data\Development\git\id-dev\Co3.ID.Dynamicweb\Models\Frontend\Ecommerce\IdentityProduct.cs:line 1006
at Co3.ID.Dw.Models.Frontend.Ecommerce.IdentityProduct.get_VariantPrimaryImages() in C:\Data\Development\git\id-dev\Co3.ID.Dynamicweb\Models\Frontend\Ecommerce\IdentityProduct.cs:line 219
at CompiledRazorTemplates.Dynamic.RazorEngine_e351aed611354b21b114cec753f2453b.Execute() in D:\dynamicweb.net\Solutions\id.espresso4.dk-e5\Application\Files\Templates\Designs\identity_v2\ecom\productlist\partials\item.cshtml:line 74
at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)
at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer)
at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
at Dynamicweb.Rendering.Template.RenderRazorTemplate()
1 @inherits ViewModelTemplate< Co3.ID.Dw.Models.Frontend.Ecommerce.IdentityProduct >
2 @using Co3.Espresso.Base.Extensions
3 @using Co3.Espresso.Website.Models.FrontEnd.Ecommerce
4 @using Co3.Espresso.Website.Models.FrontEnd.Elements
5 @using Co3.Espresso.Website.Models.FrontEnd.Handlebars
6 @using Co3.Espresso.Website.Models.FrontEnd.Settings
7 @using Co3.Espresso.Website.Services
8 @using Co3.ID.Dw.Helpers
9 @using Co3.ID.Dw.Models.Frontend.Ecommerce
10 @using Co3.ID.Dw.Models.Frontend.Users
11 @using Dynamicweb.Rendering
12 @using Co3.ID.Dw.Services
13 @using Dynamicweb.Frontend
14 @using Dynamicweb.Security.UserManagement
15 @using RenderingService = Co3.Espresso.Website.Services.RenderingService
16
17 @{
18 string productName = Model.Name;
19 string productNumber = Model.Number;
20
21 User currentUser = PageView.Current().User;
22 ShopType shopContext = SiteContext.CurrentSiteContext();
23 bool isCustomerShop = (PageView.Current().Area.Item["IsCustomerShop"] != null && (bool)PageView.Current().Area.Item["IsCustomerShop"] == true);
24 string discountGroup = currentUser != null ? currentUser.GetCustomFieldValue< string >( "DiscountGroup" ) : string.Empty;
25 bool showPrices = !isCustomerShop || UserContext.Current.CustomerShop != null && UserContext.Current.CustomerShop.Settings.ShowPrices == true;
26
27 string hoverImage = string.Empty;
28
29 if (!isCustomerShop && Model.ListItemHoverImage != null)
30 {
31 hoverImage = Model.ListItemHoverImage.Medium;
32 }
33
34 bool showBrands = Model.BrandCode == "SS" || Model.BrandCode == "GEYSER" || Model.BrandCode == "PRO WEAR";
35 }
36
37 <div class="e-block-link e-productlist-item js-e-block-link js-e-productlist-item js-e-productlist-item- p-1" data-product-id="@Model.Id" data-variant-id="@Model.VariantId" data-brand-code="@Model.BrandCode">
38 @if (showBrands)
39 {
40 <div class="productlist-brand-wrapper">
41 @if ( Model.BrandCode == "SS" )
42 {
43 @ImageService.Instance.GetSvgMarkup( "/Files/Images/products/Labels/SevenSeasByID.svg" )
44 }
45 @if ( Model.BrandCode == "GEYSER" )
46 {
47 @ImageService.Instance.GetSvgMarkup( "/Files/Images/products/Labels/GEYSER.svg" )
48 }
49 @if ( Model.BrandCode == "PRO WEAR" )
50 {
51 @ImageService.Instance.GetSvgMarkup( "/Files/Images/products/Labels/ProWearByID.svg" )
52 }
53 </div>
54 }
55
56
57 <div class="productlist-label-container">
58 @if ( Model.ProductLabels != null )
59 {
60 foreach ( IdentityProductLabel label in Model.ProductLabels )
61 {
62 <span class="productlist-label label-@label.ClassName ">@label.Text</span>
63 }
64 }
65
66 </div>
67
68 <div class="e-productlist-item-container">
69 <div class="e-productlist-item-image-container">
70 <a class="e-productlist-item-image-wrapper" href="@Model.Link">
71 <img alt="@Model.Name" class="e-productlist-item-image js-e-productlist-item-image" src="@Model.ImagePrimary.Medium" data-base-image="@Model.ImagePrimary.Medium" data-hover-image="@hoverImage">
72 </a>
73
74 @if (Model.VariantPrimaryImages != null && Model.VariantPrimaryImages.Any() )
75 {
76 <div class="identity-variant-listitem-select-option-container d-none d-md-block">
77 <div class="d-flex identity-variant-listitem-select-option-wrapper">
78
79 @{
80 int variantCount = Model.VariantPrimaryImages.Count;
81 int variantCountTake = variantCount <= 5 ? 5 : 4;
82 }
83 @foreach ( IdentityProductVariants variantImage in Model.VariantPrimaryImages.Take( variantCountTake ) )
84 {
85 if (!string.IsNullOrEmpty(variantImage.Link) && variantImage.Image != null)
86 {
87 <span class="select-option-color-wrapper js-select-option-color-wrapper">
88 <a href="@variantImage.Link"><span class="identity-variant-listitem-select-option-color js-identity-variant-listitem-select-option-color" style="background-image: url(@variantImage.Image.Small);" data-hover-image="@variantImage.Image.Medium"></span></a>
89 </span>
90 }
91
92 }
93 @if ( Model.VariantPrimaryImages.Count > 5 )
94 {
95 string moreVariantText = string.Format( "+{0}", Model.VariantPrimaryImages.Count - 4 );
96 <span class="select-option-color-wrapper bg-light variant-option-extra-count">
97 <span class="identity-variant-listitem-select-option-color">@moreVariantText</span>
98 </span>
99 }
100 </div>
101 </div>
102
103 }
104
105 </div>
106 <div class="e-productlist-item-text-container small"> @* CSS ADD text-truncate *@
107 <p class="e-productlist-item-name mb-0 list-style-d-none">
108 <a href="@Model.Link" class="text-ellipsis">
109 @Translate("eCom Product - Product Number - List - Text", "No.") @Model.Number
110 @productName
111 </a>
112 </p>
113 <p class="e-productlist-item-name mb-1 grid-style-d-none d-none">
114 <a href="@Model.Link">
115 <span class="d-block font-weight-bold">@Translate("eCom Product - Product Number - List - Text", "No.") @Model.Number</span>
116 @productName
117 </a>
118 </p>
119
120 <div class="e-productlist-item-text mb-0">
121 @if (shopContext == ShopType.B2B && string.IsNullOrEmpty(discountGroup) == false && Model.ListPrices != null && Model.ListPrices.Any())
122 {
123 <p class="e-product-price mb-0 mt-0">
124
125 @if (SiteContext.ShowPrices())
126 {
127 <span class="d-block font-weight-bold">
128 @Translate("Product Netto Price - Text", "Nettopris")
129 <span class="js-e-product-price">
130 @Model.Price.Formatted
131 </span>
132 </span>
133 }
134
135
136 <span class="d-block text-muted id-product-details-list-price">
137 @Translate("Product List Price - Text", "Listepris")
138 <span class="js-e-product-listprice">
139 @PriceService.Instance.GetPrice(new PriceSettings()
140 {
141 Value = Model.ListPrices.FirstOrDefault()?.Amount
142 })
143 </span>
144 </span>
145 </p>
146 }
147 @if (shopContext == ShopType.B2C || shopContext == ShopType.CustomerShop)
148 {
149 <p class="e-product-price mb-1 mt-0 @(SiteContext.ShowPrices() == false ? "hidden-price" : string.Empty)">
150 <span class="e-productlist-item-price">
151 <a href="@Model.Link">
152 @Model.Price.Formatted
153 </a>
154 </span>
155 <small>(@(Model.PriceWithoutVat.Value > 0 && Model.PriceWithoutVat.Value.Equals(Model.Price.Value) == false ? Model.PriceWithoutVat.Formatted : string.Empty) @Translate("Ecom - Price without VAT - text", "ekskl. moms") )</small>
156 </p>
157 }
158
159 </div>
160 @if ( Model.VariantPrimaryImages != null && Model.VariantPrimaryImages.Any() ) {
161
162 int variantCount = Model.VariantPrimaryImages.Count;
163
164 if ( Model.VariantPrimaryImages.Count > 1 ) {
165 <div class="d-block d-md-none">
166 <p class="p-0 m-0 font-weight-semibold"><small>+ @variantCount @Translate("Product List Colors - Text", "farver")</small></p>
167 </div>
168 }
169 }
170 </div>
171 @if (shopContext == ShopType.B2B || shopContext == ShopType.CustomerShop)
172 {
173 <form class="e-productlist-item-form-container d-flex justify-content-end">
174 <a class="btn btn-primary text-white mt-0 position-relative js-identity-productlist-get-variant-matrix-modal identity-productlist-get-variant-matrix-modal-btn">
175 <span class="identity-productlist-get-variant-matrix-modal-text">
176 @ImageService.Instance.GetSvgMarkup("/Files/Images/icons/outline/41-shopping/shopping-cart-add-2.svg")
177 </span>
178 </a>
179 </form>
180
181 <div class="e-loading-overlay e-productlist-loading-overlay js-e-matrix-loading-overlay">
182 @RenderingService.Instance.PartialView( "_partials/loading-spinner.cshtml" )
183 </div>
184 }
185 </div>
186 <code class="js-identity-product-data" hidden>
187 @{
188 dynamic productImperssionClick = new
189 {
190 item_name = Model.Name,
191 item_id = Model.Id,
192 price = Model.Price.Value.ToJavaScript(),
193 item_brand = Model.BrandName,
194 item_category = Model.Category,
195 item_variant = Model.ColorVariantText
196 };
197 @JsonService.Instance.ToJson(productImperssionClick)
198 }
199 </code>
200 </div>
201