Error executing template "Designs/mpdenmark/eCom/Product/espresso.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
at Co3.MPDenmark.Website.Models.Frontend.Ecommerce.MPDenmarkProduct.get_VariantCombinationTree()
at CompiledRazorTemplates.Dynamic.RazorEngine_b71eb3cd61a94a469ab8aedbde19582c.Execute() in E:\Dynamicweb.NET\Solutions\staging.mpdenmark.espresso4.dk\files\Templates\Designs\mpdenmark\eCom\Product\espresso.cshtml:line 231
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 Co3.Espresso.Website.TemplateBases.Paragraphs.Module 2 @using System.Threading.Tasks 3 @using System.Web 4 @using Co3.Espresso.Base.Extensions 5 @using Co3.Espresso.Base.Models 6 @using Co3.Espresso.Website.Services 7 @using Co3.Espresso.Website.Models.FrontEnd 8 @using Co3.Espresso.Website.Models.FrontEnd.Settings 9 @using Co3.Espresso.Website.Models.FrontEnd.Ecommerce 10 @using Co3.Espresso.Website.Models.FrontEnd.Handlebars 11 @using Co3.MPDenmark.Website.Models.Frontend.Ecommerce 12 @using Dynamicweb.Ecommerce 13 @using Dynamicweb.Ecommerce.Common 14 @using Dynamicweb.Ecommerce.Products 15 @using Dynamicweb.Ecommerce.Products.Categories 16 @using Dynamicweb.Security.UserManagement 17 @using ProductService = Co3.Espresso.Website.Services.ProductService 18 19 @{ 20 bool isUserAuthenticated = User.IsExtranetUserLoggedIn(); 21 MPDenmarkProduct espressoProduct = ( MPDenmarkProduct ) ProductService.Instance.GetEspressoProduct( 22 new ProductSettings() 23 { 24 Id = GetString( "Ecom:Product.ID" ), 25 VariantId = GetString( "Ecom:Product.VariantID" ), 26 PrimaryVariantId = GetString( "Ecom:Product.DefaultVariantComboID" ) 27 } 28 ); 29 30 31 32 // Add auto generated relation groups fra Dynamicweb to RelatedGroups dictionary, in order to access them the same way, as the custom related product groups. 33 espressoProduct.RelatedGroups.Add( espressoProduct.WhatAboutTheseProducts.Id, espressoProduct.WhatAboutTheseProducts ); 34 espressoProduct.RelatedGroups.Add( espressoProduct.CustomersWhoSawThisAlsoSaw.Id, espressoProduct.CustomersWhoSawThisAlsoSaw ); 35 espressoProduct.RelatedGroups.Add( espressoProduct.CustomersWhoBoughtThisItemAlsoBought.Id, espressoProduct.CustomersWhoBoughtThisItemAlsoBought ); 36 espressoProduct.RelatedGroups.Add( espressoProduct.YouHaveSeenTheseProducts.Id, espressoProduct.YouHaveSeenTheseProducts ); 37 38 string howItWorksPage = Espresso.Page.Area.Item[ "EcommerceHowToOrderPage" ]?.ToString(); 39 40 // Related product groups are rendered in this order. 41 string[] relatedGroupIds = 42 { 43 "RELGRP2", 44 "RELGRP4", 45 "CustomersWhoBoughtThisItemAlsoBought", 46 "YouHaveSeenTheseProducts", 47 }; 48 49 50 dynamic washingInstructions = new List< dynamic >(); 51 foreach (FieldDisplayGroupItem fieldDisplayGroup in espressoProduct.WashingsInstructions) 52 { 53 string fieldName = fieldDisplayGroup.Label; 54 string descValue = string.Format( "Ecom:Product.CategoryField.Products.{0}.OptionLabel", fieldName ); 55 string imageValue = string.Format( "Ecom:Product.CategoryField.Products.{0}Image.Value.Clean", fieldName ); 56 if ( !string.IsNullOrEmpty( GetString(descValue) ) ) 57 { 58 washingInstructions.Add( new 59 { 60 desc = GetString(descValue), 61 image = string.Format("/admin/public/getimage.ashx?Image={0}&Width=50&Height=50&Format=jpg&Quality=50&Crop=5", GetString(imageValue)) 62 } ); 63 } 64 } 65 66 Co3.MPDenmark.Website.Services.Frontend.ConversionApiService.Instance.SendViewContent(espressoProduct); 67 68 } 69 70 @GetString("Ecom:Product.CategoryField.Products.MpHalfAnkelIcon.Value.Clean") 71 72 @RenderingService.Instance.SectionEnd() 73 74 <h4 class="px-2 small text-secondary js-mpdenmark-product-number d-lg-none">@espressoProduct.Number</h4> 75 <h2 class="px-1 d-lg-none">@espressoProduct.MainProductName</h2> 76 77 <section class="e-product js-e-product" data-product-name="@espressoProduct.Name" data-product-id="@espressoProduct.Id" data-has-variants="@espressoProduct.HasVariants.ToString().ToLower()" data-variant-id="@espressoProduct.VariantId" data-brand="@espressoProduct.BrandName" data-price="@espressoProduct.Price.Value.ToJavaScript()" data-currency="@espressoProduct.Price.CurrencyCode"> 78 79 <section class="e-section pb-0 e-section-background-element"> 80 81 82 83 @*@if (espressoProduct.detailMoodImages.Count > 0) 84 { 85 <div class="background-image" style="background-image: url('@espressoProduct.detailMoodImages[0].Large')"></div> 86 } 87 else 88 { 89 <div class="background-image"></div> 90 }*@ 91 <div class="container-fluid"> 92 <div class="row"> 93 <div class="col-12"> 94 <div class="row"> 95 <div class="col-12"> 96 <div class="row"> 97 <div class="col-12 col-lg-5 col-xl-4 pb-4 pb-lg-0 offset-lg-1"> 98 <div class="e-product-text-container p-2" style="position: sticky; top: 11em;"> 99100 @RenderingService.Instance.PartialView("ecom/product/partials/add-to-cart.cshtml", espressoProduct) 101102 </div> 103 </div> 104 <div class="col-12 col-lg-5 col-xl-5 ml-auto order-first pb-lg-6"> 105106 <span class="mpdenmark-badge-image"> 107 @foreach (FieldDisplayGroupItem badge in espressoProduct.Badge) 108 { 109 if (badge.Value.Contains(".jpg") || badge.Value.Contains(".png") || badge.Value.Contains(".svg")) 110 { 111 <img src="/Files/Images/@badge.Value" style="max-height: 70px;" class="ml-1"> 112 } 113 } 114 </span> 115116 @RenderingService.Instance.PartialView("ecom/product/partials/images.cshtml", espressoProduct) 117118 </div> 119 </div> 120 </div> 121 @RenderingService.Instance.SectionEnd() 122123 <section class="e-section pb-3" id="specifications"> 124 <div class="container-fluid"> 125 <div class="row"> 126127128 <div class="col-11 px-2 px-lg-0 col-lg-6 mx-auto ml-lg-auto pb-1 pt-lg-6 mt-lg-3"> 129130 <h2 class="col-12 e-product-name">@Translate("eCom Product - Description - Heading", "Description")</h2> 131 <div class="col-12 mb-6"> 132 @if (!string.IsNullOrEmpty(espressoProduct.DescriptionLong)) 133 { 134 @espressoProduct.DescriptionLong 135 } 136 else 137 { 138 @espressoProduct.DescriptionShort 139 } 140141 </div> 142143 <h2 class="col-12 e-product-name">@Translate("eCom Product - Specifications - Heading", "Specifications")</h2> 144 <table class="table table-sm table-striped small"> 145146 @{ 147 string jsonSrc = "/system/data/product"; 148 string jsonSrcGetParams = HttpUtility.HtmlAttributeEncode(JsonService.Instance.ToJson(new Dictionary<string, string> 149 { 150 {"productId", espressoProduct.Id}, 151 {"variantId", espressoProduct.VariantId} 152 })); 153 } 154155156 <div class="js-e-jsonpublisher" data-json-src="@jsonSrc" data-json-src-get-params="@jsonSrcGetParams" data-template=".js-e-handlebars-tmpl-product-specifications" data-template-helpers="counter compare"> 157 <script class="js-e-handlebars-tmpl-product-specifications" type="text/x-handlebars-template"> 158159 {{#if Specfications}} 160 <table class="table table-sm table-striped small"> 161 {{#each Specfications}} 162 <tr> 163 <th class="pl-2" scope="row">{{this.Label}}</th> 164 <td>{{this.Value}}</td> 165 </tr> 166 {{/each}} 167 </table> 168 {{/if}} 169 </script> 170 </div> 171172 </table> 173 </div> 174175 <div class="col-11 col-lg-5 col-xl-4 px-2 px-lg-3 mx-auto mx-lg-0 ml-lg-auto mt-2"> 176177 @if (washingInstructions.Count > 0) 178 { 179 <div class="mb-5 d-flex"> 180 @if (washingInstructions.Count > 0) 181 { 182 <ul class="mpdenmark-specs-washinginstructions small"> 183 @foreach (dynamic washingInstruction in washingInstructions) 184 { 185 <li> 186 <img style="filter: contrast(0.935);" src="@washingInstruction.image" alt="@washingInstruction.desc"/>@washingInstruction.desc 187 </li> 188 } 189 </ul> 190 } 191 </div> 192 } 193194 @foreach (FieldDisplayGroupItem brand in espressoProduct.Brand) 195 { 196 if (brand.Label.Contains("image")) 197 { 198 <img alt="@brand.Label" title="@brand.Label" src="/admin/public/getimage.ashx?Image=/Files/Images/@brand.Value&Width=800&Height=800&Format=jpg&Quality=75&Crop=0" style="width: 100%"> 199 } 200 if (brand.Label.ToLower().Contains("logo")) 201 { 202 <img alt="@brand.Label" title="@brand.Label" src="/Files/Images/@brand.Value" style="filter: contrast(0.935); max-height: 40px;" class="my-2"> 203 } 204205 if (brand.Label.ToLower().Contains("desc")) 206 { 207 @brand.Value 208 } 209 } 210211 </div> 212213 </div> 214 </div> 215 </section> 216217218219 @RenderingService.Instance.PartialView("ecom/product/partials/metadata.cshtml", espressoProduct) 220 @RenderingService.Instance.PartialView("ecom/product/partials/gtm-tracking.cshtml", espressoProduct) 221 @RenderingService.Instance.PartialView("ecom/product/partials/klaviyo-viewed-product.cshtml", espressoProduct ) 222223 <code class="js-e-breadcrumb-item-append" data-text="@HttpUtility.HtmlAttributeEncode(espressoProduct.Name)" data-link="@HttpUtility.HtmlAttributeEncode(espressoProduct.Link)"></code> 224225 @{ 226 Dictionary<string, EspressoStock> variantStocks = espressoProduct.VariantCombinations.ToDictionary( vc => vc.Key, vc => vc.Value.Stock ); 227 } 228229 <script> 230 e4.data.set( 'variantStocks', JSON.parse('@HttpUtility.JavaScriptStringEncode(JsonService.Instance.ToJson(variantStocks))') ); 231 e4.data.set( '@(espressoProduct.Id)_VariantCombinationTree', JSON.parse('@HttpUtility.JavaScriptStringEncode(JsonService.Instance.ToJson(espressoProduct.VariantCombinationTree))') ); 232 e4.data.set( '@(espressoProduct.Id)_VariantCombinationIds', JSON.parse('@HttpUtility.JavaScriptStringEncode(JsonService.Instance.ToJson(espressoProduct.VariantCombinations.Keys))') ); 233 </script> 234235 </section> 236
keyboard_arrow_up