Error executing template "Designs/Swift/eCom/ProductCatalog/ProductViewDetail.cshtml"
System.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) ---> System.ComponentModel.Win32Exception (0x80004005): The network path was not found
   at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
   at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
   at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
   at System.Data.SqlClient.SqlConnection.Open()
   at Dynamicweb.Data.DatabaseConnectionProvider.CreateConnection(Boolean open)
   at Dynamicweb.Data.Database.CreateConnection()
   at Dynamicweb.Data.Database.CreateDataReader(CommandBuilder commandBuilder, IDbConnection connection, IDbTransaction transaction, Int32 commandTimeout)
   at Dynamicweb.Ecommerce.Products.DetailRepository.GetInheritedDetailsBulk(List`1 productIds, String detailType, Boolean onlyDefault)
   at Dynamicweb.Ecommerce.Products.DetailService.GetPrimaryDetailsBulk(IEnumerable`1 productKeys, String detailType)
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at Dynamicweb.Ecommerce.ProductCatalog.ViewEngine.GetDefaultImage(MediaViewModelSettings settings, String productId, String languageId, String variantId, Lazy`1 productImages, Lazy`1 details)
   at Dynamicweb.Ecommerce.ProductCatalog.ViewEngine.GetDefaultImage(MediaViewModelSettings settings, Product product, Lazy`1 productImages, Lazy`1 details)
   at Dynamicweb.Ecommerce.ProductCatalog.ViewEngine.<>c__DisplayClass3_2.<BulkCreateView>b__62()
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at CompiledRazorTemplates.Dynamic.RazorEngine_9e28e2b0299a4c73b66221e00f61950f.Execute() in C:\inetpub\solutions\Goecker-2022-Prod\Files\Templates\Designs\Swift\eCom\ProductCatalog\ProductViewDetail.cshtml:line 9
   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()
ClientConnectionId:00000000-0000-0000-0000-000000000000
Error Number:53,State:0,Class:20

1 @inherits ViewModelTemplate<ProductViewModel> 2 @using Dynamicweb.Rendering 3 @using Dynamicweb.Ecommerce.ProductCatalog 4 @using Dynamicweb.Core 5 6 @{ 7 string metaDescription = string.IsNullOrEmpty(Model.MetaDescription) ? Model.Name : Model.MetaDescription; 8 9 Pageview.Meta.AddTag($"<meta property=\"og:image\" content=\"{Dynamicweb.Context.Current.Request.Url.Scheme}://{Dynamicweb.Context.Current.Request.Url.Host}{Model.DefaultImage.Value}\">"); 10 Pageview.Meta.AddTag($"<meta property=\"og:image:alt\" content=\"{Model.Name}\">"); 11 Pageview.Meta.AddTag($"<meta property=\"og:description\" content=\"{metaDescription}\">"); 12 13 Pageview.Meta.AddTag("twitter:image", Model.DefaultImage.Value); 14 Pageview.Meta.AddTag("twitter:image:alt", Model.Name); 15 Pageview.Meta.AddTag("twitter:description", metaDescription); 16 } 17 18 @{ 19 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 20 { 21 Dynamicweb.Context.Current.Items["ProductDetails"] = Model; 22 } 23 else 24 { 25 Dynamicweb.Context.Current.Items.Add("ProductDetails", Model); 26 } 27 28 bool isLazyLoadingForProductInfoEnabled = Dynamicweb.Core.Converter.ToBoolean(Dynamicweb.Context.Current.Items["IsLazyLoadingForProductInfoEnabled"]); 29 if (isLazyLoadingForProductInfoEnabled) 30 { 31 string showPricesWithVat = Pageview.Area.EcomPricesWithVat.ToLower(); 32 bool neverShowVat = string.IsNullOrEmpty(showPricesWithVat); 33 bool hasVariantId = !string.IsNullOrEmpty(Model.VariantId); 34 string variantIdParam = hasVariantId ? $"/{Model.VariantId}" : ""; 35 string priceFilledProperties = $"Price,PriceFormatted{(showPricesWithVat == "false" && !neverShowVat ? ",PriceWithVat,PriceWithVatFormatted" : "")}"; 36 string productInfoFeed = $@"/dwapi/ecommerce/products/{Model.Id}{variantIdParam} 37 ?UserId={Converter.ToString(Pageview.User?.ID)} 38 &LanguageId={Pageview.Area.EcomLanguageId}&CurrencyCode={Pageview.Area.EcomCurrencyId}&CountryCode={Pageview.Area.EcomCountryCode}&ShopId={Pageview.Area.EcomShopId} 39 &FilledProperties=Id,Price,PriceBeforeDiscount,StockLevel,VariantInfo,NeverOutOfstock,Prices 40 &PriceSettings.ShowPricesWithVat={Pageview.Area.EcomPricesWithVat} 41 &PriceSettings.FilledProperties={priceFilledProperties} 42 &getproductinfo=true"; 43 Dynamicweb.Context.Current.Items["ProductInfoFeed"] = productInfoFeed; 44 45 <script type="module"> 46 swift.LiveProductInfo.init(); 47 </script> 48 } 49 } 50 51 <script> 52 gtag("event", "view_item", { 53 currency: "@Model.Price.CurrencyCode", 54 value: @PriceViewModelExtensions.ToStringInvariant(Model.Price), 55 items: [ 56 { 57 item_id: "@Model.Number", 58 item_name: "@Dynamicweb.Core.Encoders.HtmlEncoder.JavaScriptStringEncode(Model.Name)", 59 currency: "@Model.Price.CurrencyCode", 60 price: @PriceViewModelExtensions.ToStringInvariant(Model.Price) 61 } 62 ] 63 }); 64 </script> 65 66 <script> 67 window.addEventListener('load', function (event) { 68 swift.Video.init(); 69 }); 70 </script> 71
Error executing template "/Designs/Swift/Paragraph/Swift_BreadcrumbNavigation_Custom.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_660cb6f5a49d4b0d8baebda7d81e17f6.Execute() in C:\inetpub\solutions\Goecker-2022-Prod\Files\Templates\Designs\Swift\Paragraph\Swift_BreadcrumbNavigation_Custom.cshtml:line 17
   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 Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using Dynamicweb.Frontend.Navigation 3 @using Dynamicweb.Core 4 @using Dynamicweb.Ecommerce.ProductCatalog 5 @using Dynamicweb.Content 6 @using Dynamicweb.Frontend 7 @using System 8 9 @* CUSTOMIZED STANDARD SWIFT (v1.15.0) TEMPLATE *@ 10 11 @{ 12 ProductViewModel product = new ProductViewModel(); 13 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 14 { 15 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 16 } 17 string contentPageLink = Converter.ToString(Dynamicweb.Ecommerce.Services.ProductGroups.GetGroup(product.PrimaryOrDefaultGroup.Id)?.ProductGroupFieldValues.GetProductGroupFieldValue("ProductContentPage").Value); 18 int contentPageId = Converter.ToInt32(contentPageLink.Split('=').Last()); 19 20 if (contentPageId != 0) 21 { 22 IEnumerable<Dynamicweb.Content.Page> contentPageAncestors = Dynamicweb.Services.Pages.GetAncestors(contentPageId, true); 23 24 List<Dynamicweb.Content.Page> breadcrumbs = new List<Dynamicweb.Content.Page>(); 25 for (int i = contentPageAncestors.Count() - 1; i > 0; i--) 26 { 27 var page = contentPageAncestors.ElementAt(i); 28 if (page.ShowInSitemap) 29 { 30 breadcrumbs.Add(page); 31 } 32 else 33 { 34 break; 35 } 36 } 37 38 <ol class="breadcrumb small mb-0"> 39 @foreach (Dynamicweb.Content.Page page in breadcrumbs.Reverse<Dynamicweb.Content.Page>()) 40 { 41 string link = Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl("Default.aspx?Id=" + page.ID); 42 <li class="breadcrumb-item"> 43 <a href="@link">@page.MenuText</a> 44 </li> 45 } 46 </ol> 47 } 48 } 49 50 51
Error executing template "Designs/Swift/Paragraph/Swift_ProductDetailsImage_Custom.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at NORRIQ.CustomCode.Razor.ProductViewModelExtensions.GetAutoId(ProductViewModel product) in D:\a\1\s\NORRIQ.CustomCode\Razor\ProductViewModelExtensions.cs:line 47
   at NORRIQ.CustomCode.Razor.ProductViewModelExtensions.GetSpecifications(ProductViewModel product) in D:\a\1\s\NORRIQ.CustomCode\Razor\ProductViewModelExtensions.cs:line 26
   at CompiledRazorTemplates.Dynamic.RazorEngine_fc5528649d984b13b40dfb198a0d7806.Execute() in C:\inetpub\solutions\Goecker-2022-Prod\Files\Templates\Designs\Swift\Paragraph\Swift_ProductDetailsImage_Custom.cshtml:line 85
   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 Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using Dynamicweb.Ecommerce.ProductCatalog 3 @using Dynamicweb.Frontend 4 @using System.IO 5 @using NLWI.Core.Factory 6 @using NLWI.Platforms.Dynamicweb9.Specs.Services 7 @using NORRIQ.CustomCode.Razor 8 9 @* CUSTOMIZED STANDARD SWIFT (v1.15.0) TEMPLATE *@ 10 11 @functions { 12 public ProductViewModel product { get; set; } = new ProductViewModel(); 13 public string galleryLayout { get; set; } 14 public string[] supportedImageFormats { get; set; } 15 public string[] supportedVideoFormats { get; set; } 16 public string[] supportedDocumentFormats { get; set; } 17 public string[] allSupportedFormats { get; set; } 18 19 public class RatioSettings 20 { 21 public string Ratio { get; set; } 22 public string CssClass { get; set; } 23 public string CssVariable { get; set; } 24 public string Fill { get; set; } 25 } 26 27 public RatioSettings GetRatioSettings(string size = "desktop") 28 { 29 var ratioSettings = new RatioSettings(); 30 31 string ratio = Model.Item.GetRawValueString("ImageAspectRatio", ""); 32 ratio = ratio != "0" ? ratio : ""; 33 string cssClass = ratio != "" && ratio != "fill" ? " ratio" : ""; 34 string cssVariable = ratio != "" && ratio != "fill" ? "--bs-aspect-ratio: " + ratio : ""; 35 cssClass = ratio != "" && ratio == "fill" && size == "mobile" ? " ratio" : cssClass; 36 cssVariable = ratio != "" && ratio == "fill" && size == "mobile" ? "--bs-aspect-ratio: 66%" : cssVariable; 37 38 ratioSettings.Ratio = ratio; 39 ratioSettings.CssClass = cssClass; 40 ratioSettings.CssVariable = cssVariable; 41 ratioSettings.Fill = ratio == "fill" ? " h-100" : ""; 42 43 return ratioSettings; 44 } 45 } 46 47 @using NLWI.Platforms.Dynamicweb9.Specs.ViewModels 48 49 @functions { 50 string GetProductImage(ProductSpecifications specs) 51 { 52 string imageUrl = "/Files/Images/Perfion/default.png"; 53 54 if (specs.HasKey("Primærbillede")) 55 { 56 imageUrl = specs.GetByKey("Primærbillede").Value; 57 } 58 59 return imageUrl; 60 } 61 62 Dictionary<string, string> GetAllProductImages(ProductSpecifications specs) 63 { 64 Dictionary<string, string> images = new Dictionary<string, string>(); 65 66 foreach (var img in specs.GetByGroup("Billeder")) 67 { 68 if (!images.ContainsKey(img.Value) && img.Key != "Brandlogo") 69 { 70 images.Add(img.Value, img.Caption); 71 } 72 } 73 74 return images; 75 } 76 } 77 78 @{ 79 @* Get the product data *@ 80 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 81 { 82 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 83 } 84 85 var productSpecs = product.GetSpecifications(); 86 87 @* Supported formats *@ 88 supportedImageFormats = new string[] { ".jpg", ".jpeg", ".webp", ".png", ".gif", ".bmp", ".tiff" }; 89 supportedVideoFormats = new string[] { "youtu.be", "youtube", "vimeo", ".mp4", ".webm" }; 90 supportedDocumentFormats = new string[] { ".pdf", ".docx", ".xlsx", ".ppt", "pptx" }; 91 allSupportedFormats = supportedImageFormats.Concat(supportedVideoFormats).Concat(supportedDocumentFormats).ToArray(); 92 93 @* Collect the assets *@ 94 var selectedAssetCategories = Model.Item.GetRawValueString("ImageAssets").Split(',').ToList(); 95 bool includeImagePatternImages = Model.Item.GetBoolean("ImagePatternImages"); 96 97 @* Needed image data collection to support both DefaultImage, ImagePatterns and Image Assets *@ 98 string defaultImage = product.DefaultImage != null ? product.DefaultImage.Value : ""; 99 IEnumerable<MediaViewModel> assetsImages = product.AssetCategories.Where(x => selectedAssetCategories.Contains(x.SystemName)).SelectMany(x => x.Assets); 100 assetsImages = assetsImages.OrderByDescending(x => x.Value.Equals(defaultImage)); 101 IEnumerable<MediaViewModel> assetsList = new MediaViewModel[] { }; 102 103 assetsList = assetsList.Union(assetsImages); 104 assetsList = includeImagePatternImages ? assetsList.Union(product.ImagePatternImages) : assetsList; 105 assetsList = includeImagePatternImages && assetsList.Count() == 0 ? assetsList.Append(product.DefaultImage) : assetsList; 106 107 bool defaultImageFallback = Model.Item.GetBoolean("DefaultImageFallback"); 108 bool showOnlyPrimaryImage = Model.Item.GetBoolean("ShowOnlyPrimaryImage"); 109 110 int totalAssets = 0; 111 if (showOnlyPrimaryImage == false) 112 { 113 foreach (MediaViewModel asset in assetsList) 114 { 115 var assetValue = asset.Value.ToLower(); 116 foreach (string format in allSupportedFormats) 117 { 118 if (assetValue.Contains(format)) 119 { 120 totalAssets++; 121 } 122 } 123 } 124 } 125 126 if ((totalAssets == 0 && product.DefaultImage != null && selectedAssetCategories.Count() == 0) || (showOnlyPrimaryImage == true && product.DefaultImage != null)) 127 { 128 assetsList = new List<MediaViewModel>() { product.DefaultImage }; 129 totalAssets = 1; 130 } 131 132 @* Theme settings *@ 133 string theme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Theme")) ? " theme " + Model.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : ""; 134 135 var badgeParms = new Dictionary<string, object>(); 136 badgeParms.Add("size", "h5"); 137 badgeParms.Add("saleBadgeType", Model.Item.GetRawValue("SaleBadgeType")); 138 badgeParms.Add("saleBadgeCssClassName", Model.Item.GetRawValue("SaleBadgeDesign")); 139 badgeParms.Add("newBadgeCssClassName", Model.Item.GetRawValue("NewBadgeDesign")); 140 badgeParms.Add("newPublicationDays", Model.Item.GetInt32("NewPublicationDays")); 141 badgeParms.Add("campaignBadgesValues", Model.Item.GetRawValueString("CampaignBadges")); 142 143 bool saleBadgeEnabled = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("SaleBadgeDesign")) && Model.Item.GetRawValueString("SaleBadgeDesign") != "none" ? true : false; 144 bool newBadgeEnabled = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("NewBadgeDesign")) && Model.Item.GetRawValueString("NewBadgeDesign") != "none" ? true : false; 145 DateTime createdDate = product.Created.Value; 146 bool showBadges = saleBadgeEnabled && product.Discount.Price != 0 ? true : false; 147 showBadges = (newBadgeEnabled && Model.Item.GetInt32("NewPublicationDays") == 0) || (newBadgeEnabled && (createdDate.AddDays(Model.Item.GetInt32("NewPublicationDays")) > DateTime.Now)) ? true : showBadges; 148 showBadges = !string.IsNullOrEmpty(Model.Item.GetRawValueString("CampaignBadges")) ? true : showBadges; 149 } 150 151 @* Get assets from selected categories or get all assets *@ 152 @if (totalAssets != 0) 153 { 154 int assetNumber = 0; 155 int thumbnailNumber = 0; 156 int modalAssetNumber = 0; 157 158 string featurePostFix = Pageview.AreaSettings.GetItem("CustomSettings").GetRawValueString("FeaturePostFix_Custom", ""); 159 160 <div class="h-100@(theme) position-relative"> 161 162 @if (productSpecs.HasKey("Ikon" + featurePostFix)) 163 { 164 <div class="product-label"> 165 @foreach (var label in productSpecs.GetAllByKey("Ikon" + featurePostFix)) 166 { 167 var referenceSpecfication = label.GetReferenceSpecification(); 168 var txtcolor = "#ffffff"; 169 if (!string.IsNullOrEmpty(referenceSpecfication.GetByKey("LinkFarvekode").Value)) 170 { 171 txtcolor = referenceSpecfication.GetByKey("LinkFarvekode").Value; 172 } 173 if (referenceSpecfication.HasKey("LinkURL")) 174 { 175 <a href="@(referenceSpecfication.GetByKey("LinkURL").Value)" class="product-label-item" style="background-color:@(referenceSpecfication.GetByKey("Farvekode").Value);color:@txtcolor;"> 176 @referenceSpecfication.GetByKey("Label").Value 177 </a> 178 } 179 else 180 { 181 <span class="product-label-item" style="background-color:@(referenceSpecfication.GetByKey("Farvekode").Value);color:@txtcolor;"> 182 @referenceSpecfication.GetByKey("Label").Value 183 </span> 184 } 185 } 186 </div> 187 } 188 189 <div id="SmallScreenImages_@Model.ID" class="carousel" data-bs-ride="carousel"> 190 <div class="carousel-inner h-100"> 191 @foreach (MediaViewModel asset in assetsList) 192 { 193 var assetValue = asset.Value.ToLower(); 194 foreach (string format in allSupportedFormats) 195 { 196 if (assetValue.Contains(format)) 197 { 198 string activeSlide = assetNumber == 0 ? "active" : ""; 199 200 <div class="carousel-item @activeSlide" data-bs-interval="99999"> 201 @RenderAsset(asset, assetNumber, "mobile") 202 </div> 203 assetNumber++; 204 } 205 } 206 } 207 </div> 208 </div> 209 210 @if (totalAssets > 1) 211 { 212 <div id="SmallScreenImagesThumbnails_@Model.ID" class="grid gap-2 overflow-x-auto my-3 custom-thumbnails"> 213 @foreach (MediaViewModel asset in assetsList) 214 { 215 var assetValue = asset.Value; 216 foreach (string format in allSupportedFormats) 217 { 218 if (assetValue.Contains(format)) 219 { 220 string imagePath = Dynamicweb.Context.Current.Server.UrlEncode(assetValue); 221 imagePath = assetValue.Contains("youtu.be") || assetValue.Contains("youtube") ? "https://img.youtube.com/vi/" + assetValue.Substring(assetValue.LastIndexOf('/') + 1) + "/default.jpg" : imagePath; 222 string imagePathThumb = !imagePath.Contains("youtube") ? $"/Admin/Public/GetImage.ashx?image={imagePath}&width=160&format=webp" : imagePath; 223 string iconPath = "/Files/Templates/Designs/Swift/Assets/icons/"; 224 225 string videoId = assetValue.Substring(assetValue.LastIndexOf('/') + 1); 226 string vimeoJsClass = assetValue.Contains("vimeo") ? "js-vimeo-video-thumbnail" : ""; 227 228 bool isDocument = false; 229 foreach (string documentFormat in supportedDocumentFormats) 230 { 231 if (assetValue.Contains(documentFormat)) 232 { 233 isDocument = true; 234 } 235 } 236 237 string assetName = asset.Name; 238 assetName += !string.IsNullOrEmpty(asset.Keywords) ? " " + asset.Keywords : ""; 239 string assetTitle = !string.IsNullOrEmpty(asset.DisplayName) ? "title=\"" + asset.DisplayName + "\"" : ""; 240 241 if (!isDocument) 242 { 243 <div class="ratio ratio-4x3 border outline-none" data-bs-target="#SmallScreenImages_@Model.ID" data-bs-slide-to="@thumbnailNumber" style="cursor: pointer"> 244 <div class="d-flex align-items-center justify-content-center overflow-hidden h-100"> 245 @foreach (string videoFormat in supportedVideoFormats) 246 { //Videos 247 if (assetValue.Contains(videoFormat)) 248 { 249 <div class="icon-3 position-absolute text-light" style="z-index: 1">@ReadFile(iconPath + "play-circle.svg")</div> 250 } 251 } 252 </div> 253 <img src="@imagePathThumb" alt="@assetName" @assetTitle class="p-0 p-lg-1 @vimeoJsClass mw-100 mh-100" data-video-id="@videoId" style="object-fit: cover;"> 254 </div> 255 } 256 else 257 { 258 <a href="@assetValue" class="ratio ratio-4x3 border outline-none" style="cursor: pointer" download alt="@asset.Value"> 259 @if (asset.Value.Contains(".pdf")) 260 { 261 <div class="d-flex align-items-center justify-content-center overflow-hidden h-100"> 262 <div class="icon-3 position-absolute text-light" style="z-index: 1">@ReadFile(iconPath + "download.svg")</div> 263 </div> 264 <img src="@imagePathThumb" alt="@assetName" @assetTitle class="p-0 p-lg-1 mw-100 mh-100" style="object-fit: cover;"> 265 } 266 else 267 { 268 <div class="d-flex align-items-center justify-content-center overflow-hidden h-100"> 269 <div class="icon-3 position-absolute" style="z-index: 1">@ReadFile(iconPath + "file-text.svg")</div> 270 </div> 271 } 272 </a> 273 } 274 275 thumbnailNumber++; 276 } 277 } 278 } 279 </div> 280 } 281 282 @if (showBadges) 283 { 284 <div class="position-absolute top-0 left-0 p-2 p-lg-3"> 285 @RenderPartial("Components/EcommerceBadge.cshtml", product, badgeParms) 286 </div> 287 } 288 289 @* CAMPAIGN TEXT *@ 290 @if (productSpecs.HasKey("Kampagnetekst") && Model.Item.GetBoolean("CustomShowCampaign")) 291 { 292 @* Get the colors *@ 293 string backgroundColor = Model.Item.GetRawValueString("CustomBackgroundColor"); 294 string textColor = Model.Item.GetRawValueString("CustomTextColor"); 295 string linkColor = Model.Item.GetRawValueString("CustomLinkColor"); 296 297 <div class="card product-campaign clearfix" style="--background-color: @backgroundColor; --text-color: @textColor; --link-color: @linkColor;"> 298 <div class="card-block"> 299 @if (productSpecs.HasKey("Kampagnestart") && productSpecs.HasKey("Kampagneslut")) 300 { 301 var start = productSpecs.GetByKey("Kampagnestart").AsDate(); 302 var slut = productSpecs.GetByKey("Kampagneslut").AsDate(); 303 var nu = DateTime.Now; 304 305 if (start < nu && nu < slut) 306 { 307 <text> 308 @productSpecs.GetByKey("Kampagnetekst").Value 309 </text> 310 } 311 312 } 313 else 314 { 315 <text> 316 @productSpecs.GetByKey("Kampagnetekst").Value 317 </text> 318 } 319 </div> 320 </div> 321 } 322 </div> 323 324 @* Modal with slides *@ 325 <div class="modal fade" id="modal_@Model.ID" tabindex="-1" aria-labelledby="productDetailsGalleryModalTitle_@Model.ID" aria-hidden="true"> 326 <div class="modal-dialog modal-dialog-centered modal-xl"> 327 <div class="modal-content"> 328 <div class="modal-header visually-hidden"> 329 <h5 class="modal-title" id="productDetailsGalleryModalTitle_@Model.ID">@product.Title</h5> 330 <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> 331 </div> 332 <div class="modal-body p-2 p-lg-3 h-100"> 333 <div id="ModalCarousel_@Model.ID" class="carousel h-100" data-bs-ride="carousel"> 334 <div class="carousel-inner h-100"> 335 @foreach (MediaViewModel asset in assetsList) 336 { 337 var assetValue = !string.IsNullOrEmpty(asset.Value) ? asset.Value : product.DefaultImage.Value; 338 foreach (string format in allSupportedFormats) 339 { 340 if (assetValue.Contains(format)) 341 { 342 string imagePath = assetValue; 343 string activeSlide = modalAssetNumber == 0 ? "active" : ""; 344 345 var parms = new Dictionary<string, object>(); 346 parms.Add("cssClass", "d-block mw-100 mh-100 m-auto"); 347 parms.Add("fullwidth", true); 348 parms.Add("columns", Model.GridRowColumnCount); 349 350 <div class="carousel-item @activeSlide h-100" data-bs-interval="99999"> 351 @foreach (string imageFormat in supportedImageFormats) 352 { //Images 353 if (assetValue.Contains(imageFormat)) 354 { 355 @RenderPartial("Components/Image.cshtml", new FileViewModel { Path = imagePath }, parms) 356 } 357 } 358 359 @foreach (string videoFormat in supportedVideoFormats) 360 { //Videos 361 if (assetValue.Contains(videoFormat)) 362 { 363 @RenderVideoPlayer(asset, "modal") 364 } 365 } 366 </div> 367 368 modalAssetNumber++; 369 } 370 } 371 } 372 <button class="carousel-control-prev" type="button" data-bs-target="#ModalCarousel_@Model.ID" data-bs-slide="prev"> 373 <span class="carousel-control-prev-icon" aria-hidden="true"></span> 374 <span class="visually-hidden">@Translate("Previous")</span> 375 </button> 376 <button class="carousel-control-next" type="button" data-bs-target="#ModalCarousel_@Model.ID" data-bs-slide="next"> 377 <span class="carousel-control-next-icon" aria-hidden="true"></span> 378 <span class="visually-hidden">@Translate("Next")</span> 379 </button> 380 </div> 381 </div> 382 </div> 383 </div> 384 </div> 385 </div> 386 } 387 else if (Pageview.IsVisualEditorMode) 388 { 389 RatioSettings ratioSettings = GetRatioSettings("desktop"); 390 391 <div class="h-100 @theme"> 392 <div class="d-block @(ratioSettings.CssClass)@(ratioSettings.Fill)" style="@(ratioSettings.CssVariable)"> 393 <img src="~/Files/Images/missing_image.jpg" loading="lazy" decoding="async" class="mh-100 mw-100" style="object-fit: cover;" /> 394 </div> 395 </div> 396 } 397 398 @helper RenderAsset(MediaViewModel asset, int assetNumber, string size = "desktop") 399 { 400 string theme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("ImageTheme")) ? " theme " + Model.Item.GetRawValueString("ImageTheme").Replace(" ", "").Trim().ToLower() : ""; 401 string assetValue = asset.Value; 402 403 <div class="h-100 @(theme)"> 404 @foreach (string format in supportedImageFormats) 405 { //Images 406 if (assetValue.Contains(format)) 407 { 408 @RenderImage(asset, assetNumber, size) 409 } 410 } 411 @foreach (string format in supportedVideoFormats) 412 { //Videos 413 if (assetValue.Contains(format)) 414 { 415 if (Model.Item.GetString("OpenVideoInModal") == "true") 416 { 417 @RenderVideoScreendump(asset, assetNumber, size) 418 } 419 else 420 { 421 @RenderVideoPlayer(asset, size) 422 } 423 } 424 } 425 @foreach (string format in supportedDocumentFormats) 426 { //Documents 427 if (assetValue.Contains(format)) 428 { 429 @RenderDocument(asset, assetNumber, size) 430 } 431 } 432 </div> 433 } 434 435 @helper RenderImage(MediaViewModel asset, int number, string size = "desktop") 436 { 437 string productName = product.Name; 438 string imagePath = !string.IsNullOrEmpty(asset.Value) ? asset.Value : product.DefaultImage.Value; 439 string imageLinkPath = Dynamicweb.Context.Current.Server.UrlEncode(imagePath); 440 441 RatioSettings ratioSettings = GetRatioSettings(size); 442 443 var parms = new Dictionary<string, object>(); 444 parms.Add("alt", productName + asset.Keywords); 445 parms.Add("itemprop", "image"); 446 parms.Add("fullwidth", true); 447 parms.Add("columns", Model.GridRowColumnCount); 448 if (!string.IsNullOrEmpty(asset.DisplayName)) 449 { 450 parms.Add("title", asset.DisplayName); 451 } 452 453 if (ratioSettings.Ratio == "fill" && galleryLayout != "grid") 454 { 455 parms.Add("cssClass", "w-100 h-100 image-zoom-lg-l-hover"); 456 } 457 else 458 { 459 parms.Add("cssClass", "mw-100 mh-100"); 460 } 461 462 <a href="@imageLinkPath" class="d-block @(ratioSettings.CssClass)@(ratioSettings.Fill)" style="@(ratioSettings.CssVariable)" data-bs-toggle="modal" data-bs-target="#modal_@Model.ID"> 463 <div class="d-flex align-items-center justify-content-center overflow-hidden h-100" data-bs-target="#ModalCarousel_@Model.ID" data-bs-slide-to="@number"> 464 @RenderPartial("Components/Image.cshtml", new FileViewModel { Path = imagePath }, parms) 465 </div> 466 </a> 467 } 468 469 @helper RenderImage(string imagePath, int number, string size = "desktop") 470 { 471 string productName = product.Name; 472 string imageLinkPath = Dynamicweb.Context.Current.Server.UrlEncode(imagePath); 473 474 RatioSettings ratioSettings = GetRatioSettings(size); 475 476 var parms = new Dictionary<string, object>(); 477 parms.Add("alt", productName); 478 parms.Add("itemprop", "image"); 479 parms.Add("fullwidth", true); 480 parms.Add("columns", Model.GridRowColumnCount); 481 482 if (ratioSettings.Ratio == "fill" && galleryLayout != "grid") 483 { 484 parms.Add("cssClass", "w-100 h-100 image-zoom-lg-l-hover"); 485 } 486 else 487 { 488 parms.Add("cssClass", "mw-100 mh-100"); 489 } 490 491 <a href="@imageLinkPath" class="d-block @(ratioSettings.CssClass)@(ratioSettings.Fill)" style="@(ratioSettings.CssVariable)" data-bs-toggle="modal" data-bs-target="#modal_@Model.ID"> 492 <div class="d-flex align-items-center justify-content-center overflow-hidden h-100" data-bs-target="#ModalCarousel_@Model.ID" data-bs-slide-to="@number"> 493 @RenderPartial("Components/Image.cshtml", new FileViewModel { Path = imagePath }, parms) 494 </div> 495 </a> 496 } 497 498 @helper RenderVideoScreendump(MediaViewModel asset, int number, string size = "desktop") 499 { 500 string iconPath = "/Files/Templates/Designs/Swift/Assets/icons/"; 501 502 string videoScreendumpPath = !string.IsNullOrEmpty(asset.Value) ? asset.Value : ""; 503 string videoId = videoScreendumpPath.Substring(videoScreendumpPath.LastIndexOf('/') + 1); 504 videoScreendumpPath = videoScreendumpPath.Contains("youtu.be") || videoScreendumpPath.Contains("youtube") ? "https://img.youtube.com/vi/" + videoId + "/maxresdefault.jpg" : videoScreendumpPath; 505 506 string vimeoJsClass = videoScreendumpPath.Contains("vimeo") ? "js-vimeo-video-thumbnail" : ""; 507 videoScreendumpPath = videoScreendumpPath.Contains("vimeo") ? "" : videoScreendumpPath; 508 509 string productName = product.Name; 510 productName += !string.IsNullOrEmpty(asset.Keywords) ? " " + asset.Keywords : ""; 511 string assetTitle = !string.IsNullOrEmpty(asset.DisplayName) ? "title=\"" + asset.DisplayName + "\"" : ""; 512 513 RatioSettings ratioSettings = GetRatioSettings(size); 514 515 <div class="d-block @(ratioSettings.CssClass)@(ratioSettings.Fill)" style="@(ratioSettings.CssVariable); cursor: pointer" data-bs-toggle="modal" data-bs-target="#modal_@Model.ID"> 516 <div class="d-flex align-items-center justify-content-center overflow-hidden h-100" data-bs-target="#ModalCarousel_@Model.ID" data-bs-slide-to="@number"> 517 <div class="icon-5 position-absolute" style="z-index: 1">@ReadFile(iconPath + "play-circle.svg")</div> 518 <img src="@videoScreendumpPath" loading="lazy" decoding="async" alt="@productName" @assetTitle class="@vimeoJsClass mw-100 mh-100" data-video-id="@videoId" style="object-fit: cover;" /> 519 </div> 520 </div> 521 } 522 523 @helper RenderVideoPlayer(MediaViewModel asset, string size = "desktop") 524 { 525 string assetName = !string.IsNullOrEmpty(asset.DisplayName) ? asset.DisplayName : asset.Name; 526 string assetValue = asset.Value; 527 string videoId = asset.Value.Substring(asset.Value.LastIndexOf('/') + 1); 528 string type = assetValue.Contains("youtu.be") || assetValue.Contains("youtube") ? "youtube" : ""; 529 type = assetValue.Contains("vimeo") ? "vimeo" : type; 530 type = assetValue.Contains(".mp4") || assetValue.Contains(".webm") ? "selfhosted" : type; 531 532 string openInModal = Model.Item.GetString("OpenVideoInModal"); 533 bool autoPlay = Model.Item.GetBoolean("VideoAutoPlay"); 534 535 <div class="h-100" itemscope itemtype="https://schema.org/VideoObject"> 536 <span class="visually-hidden" itemprop="name">@assetName</span> 537 <span class="visually-hidden" itemprop="contentUrl">@asset.Value</span> 538 <span class="visually-hidden" itemprop="thumbnailUrl">@asset.Value</span> 539 540 @if (type != "selfhosted") 541 { 542 <div id="player_@(Pageview.CurrentParagraph.ID)_@(videoId)_@size" 543 class="plyr__video-embed" 544 data-plyr-provider="@(type)" 545 data-plyr-embed-id="@videoId" 546 style="--plyr-color-main: var(--swift-foreground-color); height: 100%"> 547 </div> 548 549 <script type="module" src="~/Files/Templates/Designs/Swift/Assets/js/plyr.js"></script> 550 551 <script type="module"> 552 var player = new Plyr('#player_@(Pageview.CurrentParagraph.ID)_@(videoId)_@size', { 553 type: 'video', 554 youtube: { 555 noCookie: true, 556 showinfo: 0 557 }, 558 fullscreen: { 559 enabled: true, 560 iosNative: true, 561 } 562 }); 563 564 @if (autoPlay && openInModal == "false") { 565 <text> 566 player.config.autoplay = true; 567 player.config.muted = true; 568 player.config.volume = 0; 569 player.media.loop = true; 570 571 player.on('ready', function() { 572 if (player.config.autoplay === true) { 573 player.media.play(); 574 } 575 }); 576 </text> 577 } 578 579 @if (openInModal == "true") { 580 <text> 581 var productDetailsGalleryModal = document.querySelector('#modal_@Model.ID') 582 productDetailsGalleryModal.addEventListener('hidden.bs.modal', function (event) { 583 player.media.pause(); 584 }) 585 </text> 586 } 587 </script> 588 } 589 else 590 { 591 string autoPlayAttributes = (autoPlay && openInModal == "false") ? "loop autoplay muted playsinline" : ""; 592 string videoType = Path.GetExtension(assetValue).ToLower(); 593 594 <video preload="auto" @autoPlayAttributes class="h-100 w-100" style="object-fit: cover;"> 595 <source src="@assetValue" type="video/@videoType.Replace(".", "")"> 596 </video> 597 } 598 </div> 599 } 600 601 @helper RenderDocument(MediaViewModel asset, int number, string size = "desktop") 602 { 603 string iconPath = "/Files/Templates/Designs/Swift/Assets/icons/"; 604 605 string productName = product.Name; 606 string imagePath = !string.IsNullOrEmpty(asset.Value) ? asset.Value : product.DefaultImage.Value; 607 string imageLinkPath = imagePath; 608 609 RatioSettings ratioSettings = GetRatioSettings(size); 610 611 var parms = new Dictionary<string, object>(); 612 parms.Add("alt", productName + asset.Keywords); 613 parms.Add("itemprop", "image"); 614 parms.Add("fullwidth", true); 615 parms.Add("columns", Model.GridRowColumnCount); 616 if (!string.IsNullOrEmpty(asset.DisplayName)) 617 { 618 parms.Add("title", asset.DisplayName); 619 } 620 621 if (ratioSettings.Ratio == "fill" && galleryLayout != "grid") 622 { 623 parms.Add("cssClass", "w-100 h-100 image-zoom-lg-l-hover"); 624 } 625 else 626 { 627 parms.Add("cssClass", "mw-100 mh-100"); 628 } 629 630 <a href="@imageLinkPath" class="d-block @(ratioSettings.CssClass)@(ratioSettings.Fill)" style="@(ratioSettings.CssVariable)" download alt="@Translate("Download")"> 631 <div class="d-flex align-items-center justify-content-center overflow-hidden h-100"> 632 <div class="icon-5 position-absolute" style="z-index: 1">@ReadFile(iconPath + "download.svg")</div> 633 @if (asset.Value.Contains(".pdf")) 634 { 635 @RenderPartial("Components/Image.cshtml", new FileViewModel { Path = imagePath }, parms) 636 } 637 </div> 638 </a> 639 } 640

Error executing template "Designs/Swift/Paragraph/Swift_ProductPrice_Custom.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_fafed6be1b154357b2d3e537f5f654a4.Execute() in C:\inetpub\solutions\Goecker-2022-Prod\Files\Templates\Designs\Swift\Paragraph\Swift_ProductPrice_Custom.cshtml:line 75
   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 Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using Dynamicweb.Ecommerce.ProductCatalog 3 @using Dynamicweb.Ecommerce.CustomerExperienceCenter.Favorites 4 @using System.Linq 5 @using Dynamicweb.Core 6 @using NLWI.Core.Factory 7 @using NLWI.Platforms.Dynamicweb9.Specs.ViewModels 8 @using NLWI.Platforms.Dynamicweb9.Specs.Services 9 @using NORRIQ.CustomCode.Razor 10 @using NORRIQ.CustomCode.StockLocations 11 @using System.Text; 12 @using System.Web; 13 14 @* CUSTOMIZED STANDARD SWIFT (v1.15.0) TEMPLATE *@ 15 16 @{ 17 ProductViewModel product = new ProductViewModel(); 18 19 ProductViewModelSettings productSetting = new ProductViewModelSettings 20 { 21 LanguageId = Dynamicweb.Ecommerce.Common.Context.LanguageID, 22 CurrencyCode = Dynamicweb.Ecommerce.Common.Context.Currency.Code, 23 CountryCode = Dynamicweb.Ecommerce.Common.Context.Country.Code2, 24 ShopId = Pageview.Area.EcomShopId 25 }; 26 27 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 28 { 29 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 30 } 31 else if (Pageview.Item["DummyProduct"] != null) 32 { 33 34 string dummyProductId = ""; 35 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 36 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 37 if (productList.Products != null) 38 { 39 foreach (var p in productList.Products) { dummyProductId = p.Id; } 40 ProductViewModel dummyProduct = dummyProductId != "" ? ViewModelFactory.CreateView(productSetting, dummyProductId) : new ProductViewModel(); 41 product = dummyProduct; 42 } 43 else 44 { 45 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetLastActiveProducts(1, Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 46 } 47 } 48 else if (Pageview.Item["DummyProduct"] == null) 49 { 50 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetLastActiveProducts(1, Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 51 } 52 53 string anonymousUsersLimitations = Pageview.AreaSettings.GetRawValueString("AnonymousUsers", ""); 54 bool anonymousUser = Pageview.User == null; 55 bool isErpConnectionDown = !Dynamicweb.Ecommerce.DynamicwebLiveIntegration.TemplatesHelper.IsWebServiceConnectionAvailable(); 56 bool hidePrice = anonymousUsersLimitations.Contains("price") && anonymousUser || Pageview.AreaSettings.GetBoolean("ErpDownHidePrices") && isErpConnectionDown; 57 58 string priceFontSize = Model.Item.GetRawValueString("PriceSize", "fs-2"); 59 string horizontalAlign = Model.Item.GetRawValueString("HorizontalAlignment", ""); 60 string layout = Model.Item.GetRawValueString("Layout", "horizontal"); 61 string textAlign = horizontalAlign == "center" ? "text-center" : string.Empty; 62 textAlign = horizontalAlign == "end" ? "text-end" : textAlign; 63 64 horizontalAlign = horizontalAlign == "center" && layout == "horizontal" ? "justify-content-center" : horizontalAlign; 65 horizontalAlign = horizontalAlign == "end" && layout == "horizontal" ? "justify-content-end" : horizontalAlign; 66 horizontalAlign = horizontalAlign == "center" && layout == "vertical" ? "align-items-center" : horizontalAlign; 67 horizontalAlign = horizontalAlign == "end" && layout == "vertical" ? "align-items-end" : horizontalAlign; 68 69 string flexDirection = layout == "horizontal" ? string.Empty : "flex-column"; 70 string flexGap = layout == "horizontal" ? "gap-3" : string.Empty; 71 string order = layout == "horizontal" ? string.Empty : "order-2"; 72 string theme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Theme")) ? "px-2 theme " + Model.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : ""; 73 theme = GetViewParameter("theme") != null ? GetViewParameterString("theme") : theme; 74 75 var disablePrice = product.ProductFields.ContainsKey("Custom_DisablePrice") ? Convert.ToBoolean(product.ProductFields["Custom_DisablePrice"].Value) : false; //CUSTOM 76 } 77 78 @if (!hidePrice && product.Id != null && !disablePrice) //CUSTOM 79 { 80 string showPricesWithVat = HttpContext.Current.Session["Smartpage:ShowPricesWithVat"] != null ? Convert.ToString(HttpContext.Current.Session["Smartpage:ShowPricesWithVat"]) : Pageview.Area.EcomPricesWithVat.ToLower(); 81 bool neverShowVat = string.IsNullOrEmpty(showPricesWithVat); 82 83 string priceMin = ""; 84 string priceMax = ""; 85 86 string liveInfoClass = ""; 87 string productInfoFeed = ""; 88 bool isLazyLoadingForProductInfoEnabled = Dynamicweb.Ecommerce.DynamicwebLiveIntegration.TemplatesHelper.IsLazyLoadingForProductInfoEnabled; 89 if (isLazyLoadingForProductInfoEnabled) 90 { 91 if (Dynamicweb.Context.Current.Items.Contains("ProductInfoFeed")) 92 { 93 productInfoFeed = Dynamicweb.Context.Current.Items["ProductInfoFeed"]?.ToString(); 94 if (!string.IsNullOrEmpty(productInfoFeed)) 95 { 96 productInfoFeed = $"data-product-info-feed=\"{productInfoFeed}\""; 97 } 98 } 99 liveInfoClass = "js-live-info"; 100 } 101 102 FieldValueViewModel fieldValueViewModel = null; 103 product.ProductFields.TryGetValue("SchillingShowBeforePrice", out fieldValueViewModel); 104 bool showBeforePrice = fieldValueViewModel != null ? Converter.ToBoolean(fieldValueViewModel.Value) : false; 105 106 <div class="@textAlign @liveInfoClass item_@Model.Item.SystemName.ToLower()" data-product-id="@product.Id" @productInfoFeed> 107 <div class="@priceFontSize m-0 d-flex @flexDirection @flexGap @horizontalAlign" itemprop="offers" itemscope itemtype="https://schema.org/Offer"> 108 <span itemprop="priceCurrency" content="@product.Price.CurrencyCode" class="d-none"></span> 109 110 @if (showPricesWithVat == "false" && !neverShowVat) 111 { 112 if (isLazyLoadingForProductInfoEnabled && !Pageview.IsVisualEditorMode) 113 { 114 <span itemprop="price" content="" class="d-none"></span> 115 <span class="text-decoration-line-through js-text-decoration-line-through opacity-75 me-3 text-price js-text-price d-none" data-show-if="LiveProductInfo.product.Price.Price != LiveProductInfo.product.PriceBeforeDiscount.Price"></span> 116 } 117 else 118 { 119 string beforePrice = product.PriceBeforeDiscount.PriceWithoutVatFormatted; 120 string informativePrice = product.PriceInformative.PriceWithoutVatFormatted; 121 122 <span itemprop="price" content="@product.Price.PriceWithoutVat" class="d-none"></span> 123 if (product.Price.Price != product.PriceBeforeDiscount.Price) 124 { 125 <span class="text-decoration-line-through opacity-75 @order">@beforePrice</span> 126 } 127 else if (product.PriceInformative.Price > 0) 128 { 129 <span class="text-decoration-line-through opacity-75 @order">@informativePrice</span> 130 } 131 } 132 } 133 else 134 { 135 if (isLazyLoadingForProductInfoEnabled && !Pageview.IsVisualEditorMode) 136 { 137 <span itemprop="price" content="" class="d-none"></span> 138 <span class="text-decoration-line-through js-text-decoration-line-through opacity-75 me-3 text-price js-text-price d-none" data-show-if="LiveProductInfo.product.Price.Price != LiveProductInfo.product.PriceBeforeDiscount.Price"></span> 139 } 140 else 141 { 142 string beforePrice = product.PriceBeforeDiscount.PriceFormatted; 143 string informativePrice = product.PriceInformative.PriceFormatted; 144 145 <span itemprop="price" content="@product.Price.Price" class="d-none"></span> 146 147 if (product.Price.Price != product.PriceBeforeDiscount.Price) 148 { 149 <span class="text-decoration-line-through opacity-75 @order"> 150 <span class="text-price">@beforePrice</span> 151 </span> 152 } 153 else if (product.PriceInformative.Price > 0) 154 { 155 <span class="text-decoration-line-through opacity-75 @order"> 156 <span class="text-price">@informativePrice</span> 157 </span> 158 } 159 } 160 } 161 162 @if (showPricesWithVat == "false" && !neverShowVat) 163 { 164 if (isLazyLoadingForProductInfoEnabled && !Pageview.IsVisualEditorMode) 165 { 166 <span class="text-price js-text-price"> 167 <div class="spinner-border" role="status"></div> 168 </span> 169 } 170 else 171 { 172 string price = product.Price.PriceWithoutVatFormatted; 173 if (product?.VariantInfo?.VariantInfo != null) 174 { 175 priceMin = product?.VariantInfo?.PriceMin?.PriceWithoutVatFormatted != null ? product.VariantInfo.PriceMin.PriceWithoutVatFormatted : ""; 176 priceMax = product?.VariantInfo?.PriceMax?.PriceWithoutVatFormatted != null ? product.VariantInfo.PriceMax.PriceWithoutVatFormatted : ""; 177 } 178 if (priceMin != priceMax) 179 { 180 price = priceMin + " - " + priceMax; 181 } 182 <span class="@theme"> 183 <span class="text-price">@price</span> 184 </span> 185 } 186 } 187 else 188 { 189 if (isLazyLoadingForProductInfoEnabled && !Pageview.IsVisualEditorMode) 190 { 191 <span class="text-price js-text-price"> 192 <div class="spinner-border" role="status"></div> 193 </span> 194 } 195 else 196 { 197 string price = product.Price.PriceFormatted; 198 if (product?.VariantInfo?.VariantInfo != null) 199 { 200 priceMin = product?.VariantInfo?.PriceMin?.PriceFormatted != null ? product.VariantInfo.PriceMin.PriceFormatted : ""; 201 priceMax = product?.VariantInfo?.PriceMax?.PriceFormatted != null ? product.VariantInfo.PriceMax.PriceFormatted : ""; 202 } 203 if (priceMin != priceMax) 204 { 205 price = priceMin + " - " + priceMax; 206 } 207 <span class="@theme"> 208 <span class="text-price">@price</span> 209 </span> 210 } 211 } 212 213 @* Stock state for Schema.org, start *@ 214 @{ 215 Uri url = Dynamicweb.Context.Current.Request.Url; 216 } 217 218 <link itemprop="url" href="@url"> 219 220 @{ 221 bool IsNeverOutOfStock = product.NeverOutOfstock; 222 } 223 224 @if (IsNeverOutOfStock) 225 { 226 <span itemprop="availability" class="d-none">@Translate("Available in stock")</span> 227 } 228 else 229 { 230 if (product.StockLevel > 0) 231 { 232 <span itemprop="availability" class="d-none">InStock</span> 233 } 234 else 235 { 236 <span itemprop="availability" class="d-none">OutOfStock</span> 237 } 238 } 239 @* Stock state for Schema.org, stop *@ 240 241 </div> 242 243 @if (showPricesWithVat == "false" && !neverShowVat) 244 { 245 if (isLazyLoadingForProductInfoEnabled && !Pageview.IsVisualEditorMode) 246 { 247 <small class="opacity-85 fst-normal js-text-price-with-vat d-none" data-suffix="@Translate(" Incl. VAT")"></small> 248 } 249 else 250 { 251 string price = product.Price.PriceWithVatFormatted; 252 if (product?.VariantInfo?.VariantInfo != null) 253 { 254 priceMin = product?.VariantInfo?.PriceMin?.PriceWithVatFormatted != null ? product.VariantInfo.PriceMin.PriceWithVatFormatted : ""; 255 priceMax = product?.VariantInfo?.PriceMax?.PriceWithVatFormatted != null ? product.VariantInfo.PriceMax.PriceWithVatFormatted : ""; 256 } 257 if (priceMin != priceMax) 258 { 259 price = priceMin + " - " + priceMax; 260 } 261 <small class="opacity-85 fst-normal">@price @Translate("Incl. VAT")</small> 262 } 263 } 264 </div> 265 } 266 else if (Pageview.IsVisualEditorMode) 267 { 268 <div class="alert alert-dark m-0" role="alert"> 269 <span>@Translate("No products available")</span> 270 </div> 271 } 272
Error executing template "Designs/Swift/Paragraph/Swift_ProductBrandImage_Custom.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at NORRIQ.CustomCode.Razor.ProductViewModelExtensions.GetAutoId(ProductViewModel product) in D:\a\1\s\NORRIQ.CustomCode\Razor\ProductViewModelExtensions.cs:line 47
   at CompiledRazorTemplates.Dynamic.RazorEngine_d82fd9c0f42d4adbae59ad3e0ed3d214.Execute() in C:\inetpub\solutions\Goecker-2022-Prod\Files\Templates\Designs\Swift\Paragraph\Swift_ProductBrandImage_Custom.cshtml:line 49
   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 Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using Dynamicweb.Ecommerce.ProductCatalog 3 @using Dynamicweb.Ecommerce.CustomerExperienceCenter.Favorites 4 @using ProductExtensions = NORRIQ.CustomCode.Razor.ProductViewModelExtensions; 5 @using NLWI.Platforms.Dynamicweb9.Specs.Services 6 @using NORRIQ.Common8.Factory 7 @using System.Web 8 9 @* CUSTOM TEMPLATE SUPPORTED BY SWIFT (v1.15.0) *@ 10 11 @{ 12 ProductViewModel product = new ProductViewModel(); 13 14 ProductViewModelSettings productSetting = new ProductViewModelSettings 15 { 16 LanguageId = Dynamicweb.Ecommerce.Common.Context.LanguageID, 17 CurrencyCode = Dynamicweb.Ecommerce.Common.Context.Currency.Code, 18 CountryCode = Dynamicweb.Ecommerce.Common.Context.Country.Code2, 19 ShopId = Pageview.Area.EcomShopId 20 }; 21 22 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 23 { 24 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 25 } 26 else if (Pageview.Item["DummyProduct"] != null) 27 { 28 string dummyProductId = ""; 29 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 30 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 31 if (productList.Products != null) 32 { 33 foreach (var p in productList.Products) { dummyProductId = p.Id; } 34 ProductViewModel dummyProduct = dummyProductId != "" ? ViewModelFactory.CreateView(productSetting, dummyProductId) : new ProductViewModel(); 35 product = dummyProduct; 36 } 37 else 38 { 39 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetAllProducts(Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 40 } 41 } 42 else if (Pageview.Item["DummyProduct"] == null) 43 { 44 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetAllProducts(Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 45 } 46 47 //Using old norriq code, is specificationService is removed from the project, change where we get the brand logo from 48 var specificationService = ObjectFactory.GetInstance<ProductSpecificationService>(); 49 var specs = specificationService.GetProductSpecifications(ProductExtensions.GetAutoId(product)); 50 51 string imagePath = specs.HasKey("Brandlogo") ? specs.GetByKey("Brandlogo").Value : ""; 52 imagePath = Dynamicweb.Context.Current.Server.UrlEncode(imagePath); 53 54 string ratio = Model.Item.GetRawValueString("ImageAspectRatio", ""); 55 ratio = ratio != "0" ? ratio : ""; 56 string ratioCssClass = ratio != "" ? " ratio" : ""; 57 string ratioVariable = ratio != "" ? "--bs-aspect-ratio: " + ratio : ""; 58 59 string width = Model.Item.GetRawValueString("Width", "auto"); 60 int smallImageSize = 640; 61 int largeImageSize = width == "auto" ? 1280 : Convert.ToInt32(width); 62 63 string imagePathXs = "/Admin/Public/GetImage.ashx?width=" + smallImageSize + "&image=" + imagePath + "&format=webp"; 64 string imagePathS = "/Admin/Public/GetImage.ashx?width=" + largeImageSize + "&image=" + imagePath + "&format=webp"; 65 string imagePathFallBack = "/Admin/Public/GetImage.ashx?width=" + largeImageSize + "&image=" + imagePath + "&format=webp"; 66 } 67 68 @if (product.Id != null) 69 { 70 string fullWidth = width == "auto" ? "w-100" : ""; 71 string customWidth = width != "auto" ? "style=\"width: " + width + "px\"" : "style=\"min-width: 60px\""; 72 if (!string.IsNullOrEmpty(imagePath)) 73 { 74 <div class="h-100 @fullWidth position-relative item_@Model.Item.SystemName.ToLower()" @customWidth> 75 <div class="ratio" style="@(ratioVariable)"> 76 <div class="d-flex justify-content-center align-items-center"> 77 <img id="brandlogo" 78 srcset=" 79 @imagePathXs @(smallImageSize)w, 80 @imagePathS @(largeImageSize)w" 81 sizes="(min-width: 992px) 33vw, 50vw" 82 src="@imagePathFallBack" 83 loading="lazy" 84 decoding="async" 85 class="h-100 w-100" 86 style="object-fit: contain;" 87 alt="@HttpUtility.HtmlAttributeEncode(specs.HasKey("Brandlogo") ? specs.GetByKey("Brandlogo").Caption : "")"> 88 </div> 89 </div> 90 </div> 91 } 92 } 93 else if (Pageview.IsVisualEditorMode) 94 { 95 <div class="alert alert-dark m-0">@Translate("No products available")</div> 96 } 97
Error executing template "Designs/Swift/Paragraph/Swift_ProductLeasingButton_Custom.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at NORRIQ.CustomCode.Razor.ProductViewModelExtensions.GetAutoId(ProductViewModel product) in D:\a\1\s\NORRIQ.CustomCode\Razor\ProductViewModelExtensions.cs:line 47
   at CompiledRazorTemplates.Dynamic.RazorEngine_d6e5a32cde324789b3fa6975d672d32f.Execute() in C:\inetpub\solutions\Goecker-2022-Prod\Files\Templates\Designs\Swift\Paragraph\Swift_ProductLeasingButton_Custom.cshtml:line 51
   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 Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using Dynamicweb.Ecommerce.ProductCatalog 3 @using Dynamicweb.Ecommerce.CustomerExperienceCenter.Favorites 4 @using ProductExtensions = NORRIQ.CustomCode.Razor.ProductViewModelExtensions; 5 @using NLWI.Platforms.Dynamicweb9.Specs.Services 6 @using NORRIQ.Common8.Factory 7 @using NORRIQ.CustomCode.Pricing 8 @using NORRIQ.CustomCode.Razor 9 @using System.Web 10 11 @* CUSTOM TEMPLATE SUPPORTED BY SWIFT (v1.15.0) *@ 12 13 @{ 14 ProductViewModel product = new ProductViewModel(); 15 16 ProductViewModelSettings productSetting = new ProductViewModelSettings 17 { 18 LanguageId = Dynamicweb.Ecommerce.Common.Context.LanguageID, 19 CurrencyCode = Dynamicweb.Ecommerce.Common.Context.Currency.Code, 20 CountryCode = Dynamicweb.Ecommerce.Common.Context.Country.Code2, 21 ShopId = Pageview.Area.EcomShopId 22 }; 23 24 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 25 { 26 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 27 } 28 else if (Pageview.Item["DummyProduct"] != null) 29 { 30 string dummyProductId = ""; 31 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 32 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 33 if (productList.Products != null) 34 { 35 foreach (var p in productList.Products) { dummyProductId = p.Id; } 36 ProductViewModel dummyProduct = dummyProductId != "" ? ViewModelFactory.CreateView(productSetting, dummyProductId) : new ProductViewModel(); 37 product = dummyProduct; 38 } 39 else 40 { 41 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetAllProducts(Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 42 } 43 } 44 else if (Pageview.Item["DummyProduct"] == null) 45 { 46 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetAllProducts(Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 47 } 48 49 //Using old norriq code, is specificationService is removed from the project, change where we get the data from 50 var specificationService = ObjectFactory.GetInstance<ProductSpecificationService>(); 51 var productSpecs = specificationService.GetProductSpecifications(ProductExtensions.GetAutoId(product)); 52 53 var showPricesWithVat = HttpContext.Current.Session["Smartpage:ShowPricesWithVat"] != null ? Convert.ToString(HttpContext.Current.Session["Smartpage:ShowPricesWithVat"]) : Pageview.Area.EcomPricesWithVat.ToLower(); 54 55 var productPrices = ObjectFactory.GetInstance<PriceService>().GetPrices(new[] { product.GetAutoId() }); 56 var productPrice = productPrices[product.GetAutoId()]; 57 58 var leasingPrice = product.GetLeasingPrice(productPrice); 59 var leasingAllowed = productSpecs.GetAllByKey("AllowLeasing").Any(a => a.Value.IsYes()) && showPricesWithVat == "false" && leasingPrice.HasValue; 60 } 61 62 @if (product.Id != null) 63 { 64 if (leasingAllowed) 65 { 66 <div class="d-flex flex-column"> 67 @if (Model.Item.GetBoolean("ShowLeasingPrice")) 68 { 69 <p class="mb-2 product-leasing-price">@Translate("Leasing 36 mnd:") <span class="fw-bold">@Dynamicweb.Ecommerce.Services.Currencies.FormatCurrency(Dynamicweb.Ecommerce.Common.Context.Currency, leasingPrice.Value, true)</span> @Translate("eksl. moms pr.mnd.")</p>} 70 @if (Model.Item.GetBoolean("ShowLeasingButton")) 71 { 72 <button class="btn btn-outline-primary" onclick="Form(this).addData('@HttpUtility.HtmlEncode(product.Name)', '@product.Id')" data-bs-toggle="modal" data-bs-target="#leasingModal">@Translate("Ansøg leasing (uforpligtende)")</button> 73 } 74 </div> 75 } 76 else if (Pageview.IsVisualEditorMode) 77 { 78 <div class="d-flex flex-column"> 79 @if (Model.Item.GetBoolean("ShowLeasingPrice")) 80 { 81 <p class="mb-2 product-leasing-price">@Translate("Leasing 36 mnd:") <span class="fw-bold">xxxx.xx</span> @Translate("eksl. moms pr.mnd.")</p> 82 } 83 @if (Model.Item.GetBoolean("ShowLeasingButton")) 84 { 85 <button class="btn btn-outline-primary">@Translate("Visual Editor Mode: Placeholder, no leasing on product")</button> 86 } 87 @if (!Model.Item.GetBoolean("ShowLeasingButton") && !Model.Item.GetBoolean("ShowLeasingPrice")) 88 { 89 <button class="btn btn-outline-primary">@Translate("Visual Editor Mode: Placeholder, neither price or button turned selected")</button> 90 } 91 </div> 92 } 93 } 94 else if (Pageview.IsVisualEditorMode) 95 { 96 <div class="alert alert-dark m-0">@Translate("No products available")</div> 97 } 98
Error executing template "Designs/Swift/Paragraph/Swift_ProductAddToCart_Custom.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_32ac359cc6854ac99a54cfa41b4567ac.Execute() in C:\inetpub\solutions\Goecker-2022-Prod\Files\Templates\Designs\Swift\Paragraph\Swift_ProductAddToCart_Custom.cshtml:line 58
   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 Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using Dynamicweb.Ecommerce.ProductCatalog 3 @using Dynamicweb.Ecommerce.CustomerExperienceCenter.Favorites 4 @using NLWI.Core.Factory 5 @using NLWI.Platforms.Dynamicweb9.Specs.Services 6 @using NORRIQ.CustomCode.Razor 7 @using System.Web 8 9 @* CUSTOMIZED STANDARD SWIFT (v1.15.0) TEMPLATE *@ 10 @* NOTE: Item contains unsupported itemfields: ShowAddToFavorites, ShowFavoritesSelectorMasterProduct, ShowQuantitySelector, ShowUnitsSelector, WhenVariantsExist, HideButtonText, Icon, ButtonSize, HideInventory, HideStockState, VariantSelectorServicePageId *@ 11 12 @{ 13 ProductViewModel product = new ProductViewModel(); 14 15 ProductViewModelSettings productSetting = new ProductViewModelSettings 16 { 17 LanguageId = Dynamicweb.Ecommerce.Common.Context.LanguageID, 18 CurrencyCode = Dynamicweb.Ecommerce.Common.Context.Currency.Code, 19 CountryCode = Dynamicweb.Ecommerce.Common.Context.Country.Code2, 20 ShopId = Pageview.Area.EcomShopId 21 }; 22 23 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 24 { 25 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 26 } 27 else if (Pageview.Item["DummyProduct"] != null) 28 { 29 30 string dummyProductId = ""; 31 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 32 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 33 if (productList.Products != null) 34 { 35 foreach (var p in productList.Products) { dummyProductId = p.Id; } 36 ProductViewModel dummyProduct = dummyProductId != "" ? ViewModelFactory.CreateView(productSetting, dummyProductId) : new ProductViewModel(); 37 product = dummyProduct; 38 } 39 else 40 { 41 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetAllProducts(Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 42 } 43 } 44 else if (Pageview.Item["DummyProduct"] == null) 45 { 46 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetAllProducts(Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 47 } 48 49 string fullWidth = Model.Item.GetRawValueString("HorizontalAlignment", "") == "full" ? "w-100" : ""; 50 string horizontalAlign = Model.Item.GetRawValueString("HorizontalAlignment", ""); 51 horizontalAlign = horizontalAlign == "center" ? "justify-content-center" : horizontalAlign; 52 horizontalAlign = horizontalAlign == "end" ? "justify-content-end" : horizontalAlign; 53 horizontalAlign = horizontalAlign == "full" ? "" : horizontalAlign; 54 55 string anonymousUsersLimitations = Pageview.AreaSettings.GetRawValueString("AnonymousUsers", ""); 56 bool anonymousUser = Pageview.User == null; 57 bool hideAddToCart = anonymousUsersLimitations.Contains("cart") && anonymousUser; 58 hideAddToCart = product.VariantInfo.VariantInfo != null && Model.Item.GetBoolean("CustomHideVariantSelector") ? true : hideAddToCart; 59 hideAddToCart = product.ProductFields.ContainsKey("Custom_DisablePurchase") ? Convert.ToBoolean(product.ProductFields["Custom_DisablePurchase"].Value) : hideAddToCart; //CUSTOM 60 bool hidePrice = anonymousUsersLimitations.Contains("price") && anonymousUser; 61 bool hideFavoritesSelector = !string.IsNullOrEmpty(Model.Item.GetString("CustomHideFavoritesSelector")) ? Model.Item.GetBoolean("CustomHideFavoritesSelector") : false; 62 63 var favoriteParameters = new Dictionary<string, object>(); 64 if (!anonymousUser && !hideFavoritesSelector) 65 { 66 IEnumerable<FavoriteList> favoreiteLists = Pageview.User.GetFavoriteLists(); 67 int defaultFavoriteListId = 0; 68 69 if (favoreiteLists.Count() == 1) 70 { 71 foreach (FavoriteList list in favoreiteLists) 72 { 73 defaultFavoriteListId = list.ListId; 74 } 75 } 76 77 favoriteParameters.Add("ListId", defaultFavoriteListId); 78 } 79 } 80 81 @if (!hideAddToCart && product.Id != null) 82 { 83 string url = "/Default.aspx?ID=" + (GetPageIdByNavigationTag("CartService")); 84 if (!url.Contains("LayoutTemplate")) 85 { 86 url += url.Contains("?") ? "&LayoutTemplate=Swift_MiniCart.cshtml" : "?LayoutTemplate=Swift_MiniCart.cshtml"; 87 } 88 89 var productSpecificationService = ObjectFactory.GetInstance<IProductSpecificationService>(); 90 var productSpecs = productSpecificationService.GetProductSpecifications(product.GetAutoId()); 91 92 string flexFill = Model.Item.GetRawValueString("HorizontalAlignment", "") == "full" ? "flex-fill" : ""; 93 94 string minQty = product.PurchaseMinimumQuantity != 1 ? "min=\"" + product.PurchaseMinimumQuantity.ToString() + "\"" : "min=\"1\""; 95 string stepQty = product.PurchaseQuantityStep > 1 ? product.PurchaseQuantityStep.ToString() : "1"; 96 string valueQty = product.PurchaseMinimumQuantity > product.PurchaseQuantityStep ? product.PurchaseMinimumQuantity.ToString() : stepQty; 97 string qtyValidCheck = stepQty != "1" ? "onkeyup=\"swift.Cart.QuantityValidate(event)\"" : ""; 98 99 <div class="d-flex @horizontalAlign @fullWidth item_@Model.Item.SystemName.ToLower()"> 100 <form method="post" action="@url" class="@fullWidth"> 101 <input type="hidden" name="redirect" value="false" /> 102 <input type="hidden" name="ProductId" value="@product.Id" /> 103 <input type="hidden" name="cartcmd" value="add" /> 104 105 <input type="hidden" class="js-product-id" value="@product.Id" /> 106 107 @if (!string.IsNullOrEmpty(product.VariantId)) 108 { 109 <input type="hidden" name="VariantId" value="@product.VariantId" /> 110 } 111 @if (!Model.Item.GetBoolean("CustomUseQuantitySelector")) 112 { 113 <input id="Quantity_@product.Id" name="Quantity" value="@valueQty" type="hidden"> 114 115 if (!productSpecs.GetByKey("Preorder").Value.IsYes()) 116 { 117 <button type="button" onclick="swift.Cart.Update(event)" class="btn btn-primary w-100 js-add-to-cart-button" title="@HttpUtility.HtmlEncode(Translate("Add to cart"))" id="AddToCartButton@(product.Id)">@Translate("Add to cart")</button> 118 } 119 else 120 { 121 <button type="button" class="btn btn-secondary w-100 text-uppercase" onclick="Form(this).addData('@HttpUtility.HtmlEncode(product.Name)', '@product.Id')" data-bs-toggle="modal" data-bs-target="#preorderModal"> 122 @Translate("Preorder") 123 </button> 124 } 125 } 126 else 127 { 128 <div class="input-group input-primary-button-group js-input-group d-flex flex-row flex-nowrap"> 129 <label for="Quantity_@(product.Id)" class="visually-hidden">@Translate("Quantity")</label> 130 <input id="Quantity_@product.Id" name="Quantity" value="@valueQty" step="@stepQty" @minQty class="form-control" style="max-width: 96px; min-width:64px;" type="number"> 131 <button type="button" onclick="swift.Cart.Update(event)" class="btn btn-primary flex-fill js-add-to-cart-button" title="@Translate("Add to cart")" id="AddToCartButton@(product.Id)">@Translate("Add to cart")</button> 132 </div> 133 134 if (stepQty != "1") 135 { 136 <div class="invalid-feedback d-none"> 137 @Translate("Please select a quantity that is dividable by") @stepQty 138 </div> 139 } 140 } 141 </form> 142 @if (!anonymousUser && !hideFavoritesSelector) 143 { 144 @RenderPartial("Components/ToggleFavorite.cshtml", product, favoriteParameters) 145 } 146 </div> 147 } 148 else if (!anonymousUser && !hideFavoritesSelector) 149 { 150 <div class="d-flex @horizontalAlign @fullWidth item_@Model.Item.SystemName.ToLower()"> 151 <div class="flex-fill"> 152 @Translate("Add to favorites") @RenderPartial("Components/ToggleFavorite.cshtml", product, favoriteParameters) 153 </div> 154 </div> 155 } 156 else if (Pageview.IsVisualEditorMode) 157 { 158 <div class="alert alert-dark m-0">@Translate("No products available")</div> 159 } 160
Error executing template "Designs/Swift/Paragraph/Swift_StockStatus.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_afae922e87a042e5ac71ec3c29f1333c.Execute() in C:\inetpub\solutions\Goecker-2022-Prod\Files\Templates\Designs\Swift\Paragraph\Swift_StockStatus.cshtml:line 46
   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 Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using Dynamicweb.Ecommerce.ProductCatalog 3 4 @* CUSTOMIZED SWIFT TEMPLATE *@ 5 6 @{ 7 ProductViewModel product = new ProductViewModel(); 8 9 ProductViewModelSettings productSetting = new ProductViewModelSettings 10 { 11 LanguageId = Dynamicweb.Ecommerce.Common.Context.LanguageID, 12 CurrencyCode = Dynamicweb.Ecommerce.Common.Context.Currency.Code, 13 CountryCode = Dynamicweb.Ecommerce.Common.Context.Country.Code2, 14 ShopId = Pageview.Area.EcomShopId 15 }; 16 17 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 18 { 19 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 20 } 21 else if (Pageview.Item["DummyProduct"] != null) 22 { 23 24 string dummyProductId = ""; 25 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 26 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 27 if (productList.Products != null) 28 { 29 foreach (var p in productList.Products) { dummyProductId = p.Id; } 30 ProductViewModel dummyProduct = dummyProductId != "" ? ViewModelFactory.CreateView(productSetting, dummyProductId) : new ProductViewModel(); 31 product = dummyProduct; 32 } 33 else 34 { 35 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetAllProducts(Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 36 } 37 } 38 else if (Pageview.Item["DummyProduct"] == null) 39 { 40 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetAllProducts(Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 41 } 42 43 bool IsNeverOutOfStock = product.NeverOutOfstock; 44 var stockLocations = product.StockUnits; 45 46 var disableStock = product.ProductFields.ContainsKey("Custom_DisableStock") ? Convert.ToBoolean(product.ProductFields["Custom_DisableStock"].Value) : false; //CUSTOM 47 48 if (!Model.Item.GetBoolean("HideStockState") && !disableStock) //CUSTOM 49 { 50 if (!IsNeverOutOfStock) 51 { 52 <div class="mt-3 js-stock-state d-flex flex-column gap-2"> 53 <ul class="list-group"> 54 @foreach (var stockLocation in stockLocations) 55 { 56 if (stockLocation != null) 57 { 58 var locationName = stockLocation.StockLocationName; 59 var qty = stockLocation.StockLevel; 60 <li class="list-group-item"> 61 62 <div class="product-stock-item d-flex justify-content-between"> 63 <span class="product-stock-location fs-7"> 64 @locationName 65 </span> 66 <span class="product-stock-status fs-7"> 67 <span class="icon-stock @(qty > 0 ? "icon-green" : "icon-red") position-relative"></span> 68 @(qty > 0 ? Translate("label_in_Stock", "På lager") : Translate("label_not_in_stock", "Ikke på lager")) 69 </span> 70 </div> 71 </li> 72 } 73 } 74 </ul> 75 </div> 76 } 77 } 78 }
Error executing template "Designs/Swift/Paragraph/Swift_ProductDetailsCampaignAccordion_Custom.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at NORRIQ.CustomCode.Razor.ProductViewModelExtensions.GetAutoId(ProductViewModel product) in D:\a\1\s\NORRIQ.CustomCode\Razor\ProductViewModelExtensions.cs:line 47
   at NORRIQ.CustomCode.Razor.ProductViewModelExtensions.GetSpecifications(ProductViewModel product) in D:\a\1\s\NORRIQ.CustomCode\Razor\ProductViewModelExtensions.cs:line 26
   at CompiledRazorTemplates.Dynamic.RazorEngine_d6f3cec0736141669dc31a6800db2733.Execute() in C:\inetpub\solutions\Goecker-2022-Prod\Files\Templates\Designs\Swift\Paragraph\Swift_ProductDetailsCampaignAccordion_Custom.cshtml:line 47
   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 Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using Dynamicweb.Ecommerce.ProductCatalog 3 @using NLWI.Core.Factory 4 @using NLWI.Platforms.Dynamicweb9.Specs.Services 5 @using NORRIQ.CustomCode.Razor 6 @using NORRIQ.CustomCode.Pricing 7 8 @* CUSTOM TEMPLATE SUPPORTED BY SWIFT (v1.15.0) *@ 9 10 @{ 11 ProductViewModel product = new ProductViewModel(); 12 13 ProductViewModelSettings productSetting = new ProductViewModelSettings 14 { 15 LanguageId = Dynamicweb.Ecommerce.Common.Context.LanguageID, 16 CurrencyCode = Dynamicweb.Ecommerce.Common.Context.Currency.Code, 17 CountryCode = Dynamicweb.Ecommerce.Common.Context.Country.Code2, 18 ShopId = Pageview.Area.EcomShopId 19 }; 20 21 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 22 { 23 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 24 } 25 else if (Pageview.Item["DummyProduct"] != null) 26 { 27 28 string dummyProductId = ""; 29 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 30 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 31 if (productList.Products != null) 32 { 33 foreach (var p in productList.Products) { dummyProductId = p.Id; } 34 ProductViewModel dummyProduct = dummyProductId != "" ? ViewModelFactory.CreateView(productSetting, dummyProductId) : new ProductViewModel(); 35 product = dummyProduct; 36 } 37 else 38 { 39 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetAllProducts(Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 40 } 41 } 42 else if (Pageview.Item["DummyProduct"] == null) 43 { 44 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetAllProducts(Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 45 } 46 47 var specs = product.GetSpecifications(); 48 var shopId = Pageview.Area.EcomShopId; 49 var language = Dynamicweb.Ecommerce.Services.Languages.GetLanguage(Pageview.Area.EcomLanguageId); 50 var featurePostFix = language.CountryCode == "DK" ? "" : language.Culture; 51 var backgroundColor = Model.Item.GetString("BackgroundColor"); 52 var textColor = Model.Item.GetString("TextColor"); 53 string iconPath = "/Files/Templates/Designs/Swift/Assets/icons/"; 54 55 @* CAMPAIGN TEXT *@ 56 if (specs.HasKey("Kampagnetekst")) 57 { 58 @* Get the colors *@ 59 string campaignBackgroundColor = Model.Item.GetRawValueString("CustomBackgroundColor"); 60 string campaignTextColor = Model.Item.GetRawValueString("CustomTextColor"); 61 string campaignLinkColor = Model.Item.GetRawValueString("CustomLinkColor"); 62 63 <div class="accordion mt-3" id="accordion"> 64 <div class="accordion-item" style="background-color: @campaignBackgroundColor; color: @campaignTextColor;"> 65 66 <h2 class="accordion-header" id="headingOne"> 67 <button class="accordion-button fw-bold collapsed" type="button" style="background-color: @campaignBackgroundColor; color: @campaignTextColor;" data-bs-toggle="collapse" data-bs-target="#collapseCampaign" aria-expanded="false" aria-controls="collapseCampaign"> 68 @Translate("Smartpage:Product.Details.Campaigns", "Kampagner") 69 </button> 70 </h2> 71 72 <div id="collapseCampaign" class="accordion-collapse collapse" aria-labelledby="headingOne" data-bs-parent="#accordion"> 73 <div class="accordion-body d-flex justify-content-between flex-wrap"> 74 75 <div class="product-campaign clearfix" style="--background-color: @campaignBackgroundColor; --text-color: @campaignTextColor; --link-color: @campaignLinkColor;"> 76 <div class="card-block"> 77 @if (specs.HasKey("Kampagnestart") && specs.HasKey("Kampagneslut")) 78 { 79 var start = specs.GetByKey("Kampagnestart").AsDate(); 80 var slut = specs.GetByKey("Kampagneslut").AsDate(); 81 var nu = DateTime.Now; 82 83 if (start < nu && nu < slut) 84 { 85 <text> 86 @specs.GetByKey("Kampagnetekst").Value 87 </text> 88 } 89 90 } 91 else 92 { 93 <text> 94 @specs.GetByKey("Kampagnetekst").Value 95 </text> 96 } 97 </div> 98 </div> 99 </div> 100 </div> 101 </div> 102 </div> 103 } 104 } 105
Error executing template "Designs/Swift/Paragraph/Swift_ProductDetailsAccordion.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at NORRIQ.CustomCode.Razor.ProductViewModelExtensions.GetAutoId(ProductViewModel product) in D:\a\1\s\NORRIQ.CustomCode\Razor\ProductViewModelExtensions.cs:line 47
   at NORRIQ.CustomCode.Razor.ProductViewModelExtensions.GetSpecifications(ProductViewModel product) in D:\a\1\s\NORRIQ.CustomCode\Razor\ProductViewModelExtensions.cs:line 26
   at CompiledRazorTemplates.Dynamic.RazorEngine_7f22e9cfd6e946f483eac12c47a0b0d4.Execute() in C:\inetpub\solutions\Goecker-2022-Prod\Files\Templates\Designs\Swift\Paragraph\Swift_ProductDetailsAccordion.cshtml:line 46
   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 Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using Dynamicweb.Ecommerce.ProductCatalog 3 4 @using NLWI.Core.Factory 5 @using NLWI.Platforms.Dynamicweb9.Specs.Services 6 @using NORRIQ.CustomCode.Razor 7 @using NORRIQ.CustomCode.Pricing 8 9 @{ 10 ProductViewModel product = new ProductViewModel(); 11 12 ProductViewModelSettings productSetting = new ProductViewModelSettings 13 { 14 LanguageId = Dynamicweb.Ecommerce.Common.Context.LanguageID, 15 CurrencyCode = Dynamicweb.Ecommerce.Common.Context.Currency.Code, 16 CountryCode = Dynamicweb.Ecommerce.Common.Context.Country.Code2, 17 ShopId = Pageview.Area.EcomShopId 18 }; 19 20 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 21 { 22 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 23 } 24 else if (Pageview.Item["DummyProduct"] != null) 25 { 26 27 string dummyProductId = ""; 28 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 29 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 30 if (productList.Products != null) 31 { 32 foreach (var p in productList.Products) { dummyProductId = p.Id; } 33 ProductViewModel dummyProduct = dummyProductId != "" ? ViewModelFactory.CreateView(productSetting, dummyProductId) : new ProductViewModel(); 34 product = dummyProduct; 35 } 36 else 37 { 38 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetAllProducts(Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 39 } 40 } 41 else if (Pageview.Item["DummyProduct"] == null) 42 { 43 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetAllProducts(Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 44 } 45 46 var specs = product.GetSpecifications(); 47 var shopId = Pageview.Area.EcomShopId; 48 var ls = new Dynamicweb.Ecommerce.International.LanguageService(); 49 var language = ls.GetLanguage(Pageview.Area.EcomLanguageId); 50 var featurePostFix = language.CountryCode == "DK" ? "" : language.Culture; 51 var backgroundColor = Model.Item.GetString("BackgroundColor"); 52 var textColor = Model.Item.GetString("TextColor"); 53 string iconPath = "/Files/Templates/Designs/Swift/Assets/icons/"; 54 55 <div class="accordion mt-3" id="accordion"> 56 @if (specs.GetAllByKey("Produktekspert" + featurePostFix).Any() && !Model.Item.GetBoolean("HideProductExperts")) 57 { 58 <div class="accordion-item"> 59 60 <h2 class="accordion-header" id="headingOne"> 61 <button class="accordion-button fw-bold collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapseOne" aria-expanded="false" aria-controls="collapseOne"> 62 <img src="@(iconPath)users.svg" class="me-2" /> 63 @Translate("Smartpage:Product.Details.Product experts", "Produkteksperter") 64 </button> 65 </h2> 66 67 <div id="collapseOne" class="accordion-collapse collapse" aria-labelledby="headingOne" data-bs-parent="#accordion"> 68 <div class="accordion-body d-flex justify-content-between flex-wrap"> 69 70 71 @foreach (var expert in specs.GetAllByKey("Produktekspert" + featurePostFix)) 72 { 73 var referenceSpecfication = expert.GetReferenceSpecification(); 74 75 var image = "~/Files/Images/missing_image.jpg"; 76 foreach (var test in referenceSpecfication.GetAllAvailableKeys()) 77 { 78 if (referenceSpecfication.GetByKey(test).Value.Contains("Images/Perfion")) 79 { 80 image = referenceSpecfication.GetByKey(test).Value; 81 } 82 } 83 <div class="expert-container d-flex"> 84 <img src="/Admin/Public/GetImage.ashx?Image=@image&Width=60&Height=60&Crop=5&Compression=85" width="60" height="60" /> 85 <div class="info ms-2 fs-7"> 86 <strong>@referenceSpecfication.GetByKey("Value").Value</strong><br /> 87 <a href="mailto:@referenceSpecfication.GetByKey("Email").Value" class="link-primary">@referenceSpecfication.GetByKey("Email").Value</a><br /> 88 <span class="icon-phone"></span> 89 @referenceSpecfication.GetByKey("Telefonnr").Value<br /> 90 @if (referenceSpecfication.HasKey("Lokation")) 91 { 92 <span class="icon-map"></span> 93 @referenceSpecfication.GetByKey("Lokation").Value 94 }<br /><br /> 95 </div> 96 </div> 97 } 98 </div> 99 </div> 100 </div> 101 } 102 103 @if (specs.GetAllByKey("PDFbrochure").Any()) 104 { 105 <div class="accordion-item"> 106 107 <h2 class="accordion-header" id="headingTwo"> 108 <button class="accordion-button collapsed fw-bold" type="button" data-bs-toggle="collapse" data-bs-target="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo"> 109 <img src="@(iconPath)file.svg" class="me-2" /> 110 @Translate("Brochurer og tech. Info") 111 </button> 112 </h2> 113 114 <div id="collapseTwo" class="accordion-collapse collapse" aria-labelledby="headingTwo" data-bs-parent="#accordion"> 115 <div class="accordion-body d-flex flex-column justify-content-between flex-wrap gap-2"> 116 @foreach (var pdfbrochure in specs.GetAllByKey("PDFbrochure")) 117 { 118 <div class="d-flex align-items-center"> 119 <img src="@(iconPath)file.svg" class="me-2" /> 120 <a href="@(pdfbrochure.Value)" class="text-decoration-none" target="_blank"> 121 @Translate("Produkt brochure") 122 </a> 123 </div> 124 } 125 @foreach (var pdfmanual in specs.GetAllByKey("PDFmanual")) 126 { 127 <div class="d-flex align-items-center"> 128 <img src="@(iconPath)file.svg" class="me-2" /> 129 <a href="@(pdfmanual.Value)" class="text-decoration-none" target="_blank"> 130 @Translate("Produkt manual") 131 </a> 132 </div> 133 } 134 @foreach (var pdfbrochure in specs.GetAllByKey("PDFreview")) 135 { 136 <div class="d-flex align-items-center"> 137 <img src="@(iconPath)file.svg" class="me-2" /> 138 <a href="@(pdfbrochure.Value)" class="text-decoration-none" target="_blank"> 139 @Translate("Produkt review") 140 </a> 141 </div> 142 } 143 </div> 144 </div> 145 </div> 146 } 147 148 149 @if (!Model.Item.GetBoolean("HideFactSheetLink")) 150 { 151 string sheetId = Model.Item.GetString("PerfionDatasheetId"); 152 153 <div class="accordion-item"> 154 <h2 class="accordion-header" id="headingTwo"> 155 <button class="accordion-button collapsed fw-bold noafter" type="button" onclick="window.open('/Handlers/DownloadPerfionDocument.ashx?number=@(product.Number)&reportId=@(sheetId)&language=@Translate("perfion_language","DAN")')" rel="nofollow" target="_blank"> 156 <img src="@(iconPath)download.svg" class="me-2" /> 157 @Translate("Smartpage:Product.Details.Printable fact sheet", "Printbar fakta side") 158 </button> 159 </h2> 160 </div> 161 } 162 </div> 163 }

Error executing template "/Designs/Swift/Paragraph/Swift_RelatedProducts_Custom.cshtml"
System.ArgumentNullException: Value cannot be null.
Parameter name: source
   at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source, Func`2 predicate)
   at CompiledRazorTemplates.Dynamic.RazorEngine_d02035d010f04f86a19d37fbf903cd3e.Execute() in C:\inetpub\solutions\Goecker-2022-Prod\Files\Templates\Designs\Swift\Paragraph\Swift_RelatedProducts_Custom.cshtml:line 33
   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 Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using Dynamicweb.Ecommerce.ProductCatalog 3 @using NLWI.Core.Factory 4 @using NORRIQ.CustomCode.ProductRental.Services 5 6 @* CUSTOMIZED STANDARD SWIFT (v1.15.0) TEMPLATE *@ 7 8 @{ 9 ProductViewModel product = new ProductViewModel(); 10 11 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 12 { 13 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 14 } 15 16 if (product != null) 17 { 18 var rentalService = ObjectFactory.GetInstance<RentalProductService>(); 19 20 var uniqueId = Pageview.CurrentParagraph.ID.ToString(); 21 string title = Model?.Item?.GetString("Title") != null ? Model.Item.GetString("Title") : Translate("Products"); 22 string titleFontSize = Model.Item.GetRawValueString("TitleFontSize", "display-6"); 23 bool hideTitle = Model.Item.GetBoolean("HideTitle"); 24 25 // Slider settings 26 int itemsInSlider = Model.Item.GetInt32("ItemsInSlider") == 0 ? 4 : Model.Item.GetInt32("ItemsInSlider"); 27 string enableControls = Model.Item.GetBoolean("EnableControls").ToString().ToLower(); 28 string enableIndcators = Model.Item.GetBoolean("EnableIndicators").ToString().ToLower(); 29 bool autoplay = Model.Item.GetBoolean("Autoplay"); 30 string interval = (autoplay) ? Model.Item.GetString("Interval", "5000") : "0"; 31 string enableAutoplay = autoplay.ToString().ToLower(); 32 33 bool isRental = rentalService.IsRentalProduct(product); 34 string theme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Theme")) ? " theme " + Model.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : ""; 35 var productRelations = product.GetRelatedProducts(); 36 37 if (productRelations.Any()) 38 { 39 <div class="@(theme) related-products slider-wrapper-custom"> 40 @if (!hideTitle) 41 { 42 <h3 class="@titleFontSize text-center text-md-start">@title</h3> 43 } 44 45 <div class="related-products-slider js-slider" data-slider-items="@itemsInSlider"> 46 @foreach (var relatedProduct in productRelations) 47 { 48 var productParams = new Dictionary<string, object>() 49 { 50 { "product", relatedProduct } 51 }; 52 53 if (isRental) 54 { 55 @RenderPartial("Paragraph/Partials/RelatedRentalProduct.cshtml", Model, productParams); 56 } 57 else 58 { 59 @RenderPartial("Paragraph/Partials/RelatedProduct_Custom.cshtml", Model, productParams); 60 } 61 } 62 </div> 63 </div> 64 } 65 } 66 } 67

Error executing template "Designs/Swift/Paragraph/Swift_ProductSpecification_Custom.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at NORRIQ.CustomCode.Razor.ProductViewModelExtensions.GetAutoId(ProductViewModel product) in D:\a\1\s\NORRIQ.CustomCode\Razor\ProductViewModelExtensions.cs:line 47
   at NORRIQ.CustomCode.Razor.ProductViewModelExtensions.GetSpecifications(ProductViewModel product) in D:\a\1\s\NORRIQ.CustomCode\Razor\ProductViewModelExtensions.cs:line 26
   at CompiledRazorTemplates.Dynamic.RazorEngine_f17413ea9c3943c3861b0885b692ff16.Execute() in C:\inetpub\solutions\Goecker-2022-Prod\Files\Templates\Designs\Swift\Paragraph\Swift_ProductSpecification_Custom.cshtml:line 48
   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 Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using Dynamicweb.Ecommerce.ProductCatalog 3 @using NLWI.Core.Factory 4 @using NORRIQ.CustomCode.Razor 5 @using System.Web 6 7 @* CUSTOMIZED STANDARD SWIFT (v1.15.0) TEMPLATE *@ 8 9 @{ 10 bool isVisualEditor = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("VisualEdit")) ? Convert.ToBoolean(Dynamicweb.Context.Current.Request.QueryString.Get("VisualEdit")) : false; 11 12 ProductViewModel product = new ProductViewModel(); 13 14 ProductViewModelSettings productSetting = new ProductViewModelSettings 15 { 16 LanguageId = Dynamicweb.Ecommerce.Common.Context.LanguageID, 17 CurrencyCode = Dynamicweb.Ecommerce.Common.Context.Currency.Code, 18 CountryCode = Dynamicweb.Ecommerce.Common.Context.Country.Code2, 19 ShopId = Pageview.Area.EcomShopId 20 }; 21 22 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 23 { 24 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 25 } 26 else if (Pageview.Item["DummyProduct"] != null) 27 { 28 29 string dummyProductId = ""; 30 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 31 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 32 if (productList.Products != null) 33 { 34 foreach (var p in productList.Products) { dummyProductId = p.Id; } 35 ProductViewModel dummyProduct = dummyProductId != "" ? ViewModelFactory.CreateView(productSetting, dummyProductId) : new ProductViewModel(); 36 product = dummyProduct; 37 } 38 else 39 { 40 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetAllProducts(Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 41 } 42 } 43 else if (Pageview.Item["DummyProduct"] == null) 44 { 45 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetAllProducts(Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 46 } 47 48 var specs = product.GetSpecifications(); 49 } 50 51 52 @if (specs.GetByGroup("Specifikationer").Any()) 53 { 54 var prodSpecs = specs.GetByGroup("Specifikationer"); 55 bool hideTitle = Model.Item.GetBoolean("HideTitle"); 56 string titleFontSize = Model.Item.GetRawValueString("TitleFontSize", "display-4"); 57 58 <div> 59 @if (!hideTitle) 60 { 61 <div class="text-start pb-2 pb-lg-4"> 62 <h2 class="@titleFontSize">@Model.Item.GetString("Title")</h2> 63 </div> 64 } 65 <div class="tab-pane" role="tabpanel" id="specs"> 66 <div class="table-responsive"> 67 <table class="table table-specs table-striped" style="table-layout: fixed"> 68 <tbody> 69 @foreach (var specKey in prodSpecs.GetAvailableKeys()) 70 { 71 var spec = prodSpecs.GetByKey(specKey, ","); 72 <tr> 73 <td class="table-specs-label fw-bold"> 74 @(spec.Caption) 75 </td> 76 <td class="table-specs-value"> 77 @spec.Value @spec.Unit 78 </td> 79 </tr> 80 } 81 </tbody> 82 </table> 83 </div> 84 </div> 85 </div> 86 }