Error executing template "Designs/Swift/eCom/ProductCatalog/ProductViewDetail.cshtml" System.Data.SqlClient.SqlException (0x80131904): A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 0 - An existing connection was forcibly closed by the remote host.) ---> System.ComponentModel.Win32Exception (0x80004005): An existing connection was forcibly closed by the remote host 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_fb801d56af7e40faba76a92fe2bb6a5f.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:94cfbea3-2aa2-4b4a-870c-547d866450c6 Error Number:10054,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_2c650cf3bdfa42dbab67ef8c59d5b763.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_4d67b6e0fcbf471590e45342b1f05f5c.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.OrderBy(a => a.DisplayName)) 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.OrderBy(a => a.DisplayName)) 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.OrderBy(a => a.DisplayName)) 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_de072a56a0da443d9591bae7f2b1a1f2.Execute() in C:\inetpub\solutions\Goecker-2022-Prod\Files\Templates\Designs\Swift\Paragraph\Swift_ProductPrice_Custom.cshtml:line 76 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 @using System.Globalization 14 15 @* CUSTOMIZED STANDARD SWIFT (v1.15.0) TEMPLATE *@ 16 17 @{ 18 ProductViewModel product = new ProductViewModel(); 19 20 ProductViewModelSettings productSetting = new ProductViewModelSettings 21 { 22 LanguageId = Dynamicweb.Ecommerce.Common.Context.LanguageID, 23 CurrencyCode = Dynamicweb.Ecommerce.Common.Context.Currency.Code, 24 CountryCode = Dynamicweb.Ecommerce.Common.Context.Country.Code2, 25 ShopId = Pageview.Area.EcomShopId 26 }; 27 28 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 29 { 30 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 31 } 32 else if (Pageview.Item["DummyProduct"] != null) 33 { 34 35 string dummyProductId = ""; 36 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 37 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 38 if (productList.Products != null) 39 { 40 foreach (var p in productList.Products) { dummyProductId = p.Id; } 41 ProductViewModel dummyProduct = dummyProductId != "" ? ViewModelFactory.CreateView(productSetting, dummyProductId) : new ProductViewModel(); 42 product = dummyProduct; 43 } 44 else 45 { 46 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetLastActiveProducts(1, Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 47 } 48 } 49 else if (Pageview.Item["DummyProduct"] == null) 50 { 51 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetLastActiveProducts(1, Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 52 } 53 54 string anonymousUsersLimitations = Pageview.AreaSettings.GetRawValueString("AnonymousUsers", ""); 55 bool anonymousUser = Pageview.User == null; 56 bool isErpConnectionDown = false;//ynamicweb.Ecommerce.DynamicwebLiveIntegration.TemplatesHelper.IsWebServiceConnectionAvailable(); 57 bool hidePrice = anonymousUsersLimitations.Contains("price") && anonymousUser || Pageview.AreaSettings.GetBoolean("ErpDownHidePrices") && isErpConnectionDown; 58 59 string priceFontSize = Model.Item.GetRawValueString("PriceSize", "fs-2"); 60 string horizontalAlign = Model.Item.GetRawValueString("HorizontalAlignment", ""); 61 string layout = Model.Item.GetRawValueString("Layout", "horizontal"); 62 string textAlign = horizontalAlign == "center" ? "text-center" : string.Empty; 63 textAlign = horizontalAlign == "end" ? "text-end" : textAlign; 64 65 horizontalAlign = horizontalAlign == "center" && layout == "horizontal" ? "justify-content-center" : horizontalAlign; 66 horizontalAlign = horizontalAlign == "end" && layout == "horizontal" ? "justify-content-end" : horizontalAlign; 67 horizontalAlign = horizontalAlign == "center" && layout == "vertical" ? "align-items-center" : horizontalAlign; 68 horizontalAlign = horizontalAlign == "end" && layout == "vertical" ? "align-items-end" : horizontalAlign; 69 70 string flexDirection = layout == "horizontal" ? string.Empty : "flex-column"; 71 string flexGap = layout == "horizontal" ? "gap-3" : string.Empty; 72 string order = layout == "horizontal" ? string.Empty : "order-2"; 73 string theme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Theme")) ? "px-2 theme " + Model.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : ""; 74 theme = GetViewParameter("theme") != null ? GetViewParameterString("theme") : theme; 75 76 var disablePrice = product.ProductFields.ContainsKey("Custom_DisablePrice") ? Convert.ToBoolean(product.ProductFields["Custom_DisablePrice"].Value) : false; //CUSTOM 77 } 78 79 @if (!hidePrice && product.Id != null && !disablePrice) //CUSTOM 80 { 81 string showPricesWithVat = HttpContext.Current.Session["Smartpage:ShowPricesWithVat"] != null ? Convert.ToString(HttpContext.Current.Session["Smartpage:ShowPricesWithVat"]) : Pageview.Area.EcomPricesWithVat.ToLower(); 82 bool neverShowVat = string.IsNullOrEmpty(showPricesWithVat); 83 84 string priceMin = ""; 85 string priceMax = ""; 86 87 string liveInfoClass = ""; 88 string productInfoFeed = ""; 89 bool isLazyLoadingForProductInfoEnabled = Dynamicweb.Ecommerce.DynamicwebLiveIntegration.TemplatesHelper.IsLazyLoadingForProductInfoEnabled; 90 if (isLazyLoadingForProductInfoEnabled) 91 { 92 if (Dynamicweb.Context.Current.Items.Contains("ProductInfoFeed")) 93 { 94 productInfoFeed = Dynamicweb.Context.Current.Items["ProductInfoFeed"]?.ToString(); 95 if (!string.IsNullOrEmpty(productInfoFeed)) 96 { 97 productInfoFeed = $"data-product-info-feed=\"{productInfoFeed}\""; 98 } 99 } 100 liveInfoClass = "js-live-info"; 101 } 102 103 FieldValueViewModel fieldValueViewModel = null; 104 product.ProductFields.TryGetValue("SchillingShowBeforePrice", out fieldValueViewModel); 105 bool showBeforePrice = fieldValueViewModel != null ? Converter.ToBoolean(fieldValueViewModel.Value) : false; 106 107 <div class="@textAlign @liveInfoClass item_@Model.Item.SystemName.ToLower()" data-product-id="@product.Id" @productInfoFeed> 108 <div class="@priceFontSize m-0 d-flex @flexDirection @flexGap @horizontalAlign" itemprop="offers" itemscope itemtype="https://schema.org/Offer"> 109 <span itemprop="priceCurrency" content="@product.Price.CurrencyCode" class="d-none"></span> 110 111 @if (showPricesWithVat == "false" && !neverShowVat) 112 { 113 if (isLazyLoadingForProductInfoEnabled && !Pageview.IsVisualEditorMode) 114 { 115 <span itemprop="price" content="" class="d-none"></span> 116 <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> 117 } 118 else 119 { 120 string beforePrice = product.PriceBeforeDiscount.PriceWithoutVatFormatted; 121 string informativePrice = product.PriceInformative.PriceWithoutVatFormatted; 122 123 <span itemprop="price" content="@product.Price.PriceWithoutVat.ToString("0.00", CultureInfo.InvariantCulture)" class="d-none"></span> 124 if (product.Price.Price != product.PriceBeforeDiscount.Price) 125 { 126 <span class="text-decoration-line-through opacity-75 @order">@beforePrice</span> 127 } 128 else if (product.PriceInformative.Price > 0) 129 { 130 <span class="text-decoration-line-through opacity-75 @order">@informativePrice</span> 131 } 132 } 133 } 134 else 135 { 136 if (isLazyLoadingForProductInfoEnabled && !Pageview.IsVisualEditorMode) 137 { 138 <span itemprop="price" content="" class="d-none"></span> 139 <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> 140 } 141 else 142 { 143 string beforePrice = product.PriceBeforeDiscount.PriceFormatted; 144 string informativePrice = product.PriceInformative.PriceFormatted; 145 146 <span itemprop="price" content="@product.Price.Price.ToString("0.00", CultureInfo.InvariantCulture)" class="d-none"></span> 147 148 if (product.Price.Price != product.PriceBeforeDiscount.Price) 149 { 150 <span class="text-decoration-line-through opacity-75 @order"> 151 <span class="text-price">@beforePrice</span> 152 </span> 153 } 154 else if (product.PriceInformative.Price > 0) 155 { 156 <span class="text-decoration-line-through opacity-75 @order"> 157 <span class="text-price">@informativePrice</span> 158 </span> 159 } 160 } 161 } 162 163 @if (showPricesWithVat == "false" && !neverShowVat) 164 { 165 if (isLazyLoadingForProductInfoEnabled && !Pageview.IsVisualEditorMode) 166 { 167 <span class="text-price js-text-price"> 168 <div class="spinner-border" role="status"></div> 169 </span> 170 } 171 else 172 { 173 string price = product.Price.PriceWithoutVatFormatted; 174 if (product?.VariantInfo?.VariantInfo != null) 175 { 176 priceMin = product?.VariantInfo?.PriceMin?.PriceWithoutVatFormatted != null ? product.VariantInfo.PriceMin.PriceWithoutVatFormatted : ""; 177 priceMax = product?.VariantInfo?.PriceMax?.PriceWithoutVatFormatted != null ? product.VariantInfo.PriceMax.PriceWithoutVatFormatted : ""; 178 } 179 if (priceMin != priceMax) 180 { 181 price = priceMin + " - " + priceMax; 182 } 183 <span class="@theme"> 184 <span class="text-price">@price</span> 185 </span> 186 } 187 } 188 else 189 { 190 if (isLazyLoadingForProductInfoEnabled && !Pageview.IsVisualEditorMode) 191 { 192 <span class="text-price js-text-price"> 193 <div class="spinner-border" role="status"></div> 194 </span> 195 } 196 else 197 { 198 string price = product.Price.PriceFormatted; 199 if (product?.VariantInfo?.VariantInfo != null) 200 { 201 priceMin = product?.VariantInfo?.PriceMin?.PriceFormatted != null ? product.VariantInfo.PriceMin.PriceFormatted : ""; 202 priceMax = product?.VariantInfo?.PriceMax?.PriceFormatted != null ? product.VariantInfo.PriceMax.PriceFormatted : ""; 203 } 204 if (priceMin != priceMax) 205 { 206 price = priceMin + " - " + priceMax; 207 } 208 <span class="@theme"> 209 <span class="text-price">@price</span> 210 </span> 211 } 212 } 213 214 @* Stock state for Schema.org, start *@ 215 @{ 216 Uri url = Dynamicweb.Context.Current.Request.Url; 217 } 218 219 @{ 220 // Custom: ViaBill integration 221 if (Model.Item.GetBoolean("CustomActivateViaBill") && showPricesWithVat != "false") 222 { 223 <div class="viabill-pricetag" 224 data-view="product" 225 data-price="@product.Price.Price.ToString("0.00", CultureInfo.InvariantCulture)" 226 data-currency="@Dynamicweb.Ecommerce.Common.Context.Currency.Code" 227 data-dynamic-price-trigger-delay="@Model.Item.GetInt32("CustomViaBillPriceDelay")"></div> 228 @Model.Item.GetRawValueString("CustomViaBillScript") 229 } 230 231 // Custom: Anyday integration 232 if (Model.Item.GetBoolean("CustomActivateAnyday") && !String.IsNullOrEmpty(Model.Item.GetRawValueString("CustomAnydayToken")) && showPricesWithVat != "false") 233 { 234 var locale = Dynamicweb.Frontend.PageView.Current().Area.CultureInfo.ToString(); 235 <anyday-price-widget theme="@Model.Item.GetRawValueString("CustomAnydayTheme")" 236 currency="@product.Price.CurrencyCode" 237 price="@product.Price.Price" 238 price-format-locale="@locale" 239 locale="@locale" 240 token="@Model.Item.GetRawValueString("CustomAnydayToken")" 241 fully-clickable="true" 242 debug="info"> 243 </anyday-price-widget> 244 245 @Model.Item.GetRawValueString("CustomAnydayScript") 246 } 247 } 248 249 250 <link itemprop="url" href="@url"> 251 252 @{ 253 bool IsNeverOutOfStock = product.NeverOutOfstock; 254 } 255 256 @if (IsNeverOutOfStock) 257 { 258 <span itemprop="availability" class="d-none">@Translate("Available in stock")</span> 259 } 260 else 261 { 262 if (product.StockLevel > 0) 263 { 264 <span itemprop="availability" class="d-none">InStock</span> 265 } 266 else 267 { 268 <span itemprop="availability" class="d-none">OutOfStock</span> 269 } 270 } 271 @* Stock state for Schema.org, stop *@ 272 273 </div> 274 275 @if (showPricesWithVat == "false" && !neverShowVat) 276 { 277 if (isLazyLoadingForProductInfoEnabled && !Pageview.IsVisualEditorMode) 278 { 279 <small class="opacity-85 fst-normal js-text-price-with-vat d-none" data-suffix="@Translate(" Incl. VAT")"></small> 280 } 281 else 282 { 283 string price = product.Price.PriceWithVatFormatted; 284 if (product?.VariantInfo?.VariantInfo != null) 285 { 286 priceMin = product?.VariantInfo?.PriceMin?.PriceWithVatFormatted != null ? product.VariantInfo.PriceMin.PriceWithVatFormatted : ""; 287 priceMax = product?.VariantInfo?.PriceMax?.PriceWithVatFormatted != null ? product.VariantInfo.PriceMax.PriceWithVatFormatted : ""; 288 } 289 if (priceMin != priceMax) 290 { 291 price = priceMin + " - " + priceMax; 292 } 293 <small class="opacity-85 fst-normal">@price @Translate("Incl. VAT")</small> 294 } 295 } 296 </div> 297 } 298 else if (Pageview.IsVisualEditorMode) 299 { 300 <div class="alert alert-dark m-0" role="alert"> 301 <span>@Translate("No products available")</span> 302 </div> 303 } 304
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_c36afa18ccd94aa68db053a7d92c868a.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_fd844e20aed64bb6b8ce0e4357cf0f92.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_d6359ae6a0aa4ee391b0af0ba28ddb95.Execute() in C:\inetpub\solutions\Goecker-2022-Prod\Files\Templates\Designs\Swift\Paragraph\Swift_ProductAddToCart_Custom.cshtml:line 60 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 @using System.Globalization 9 @using Dynamicweb.Core.Encoders 10 11 @* CUSTOMIZED STANDARD SWIFT (v1.15.0) TEMPLATE *@ 12 @* NOTE: Item contains unsupported itemfields: ShowAddToFavorites, ShowFavoritesSelectorMasterProduct, ShowQuantitySelector, ShowUnitsSelector, WhenVariantsExist, HideButtonText, Icon, ButtonSize, HideInventory, HideStockState, VariantSelectorServicePageId *@ 13 14 @{ 15 ProductViewModel product = new ProductViewModel(); 16 17 ProductViewModelSettings productSetting = new ProductViewModelSettings 18 { 19 LanguageId = Dynamicweb.Ecommerce.Common.Context.LanguageID, 20 CurrencyCode = Dynamicweb.Ecommerce.Common.Context.Currency.Code, 21 CountryCode = Dynamicweb.Ecommerce.Common.Context.Country.Code2, 22 ShopId = Pageview.Area.EcomShopId 23 }; 24 25 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 26 { 27 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 28 } 29 else if (Pageview.Item["DummyProduct"] != null) 30 { 31 32 string dummyProductId = ""; 33 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 34 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 35 if (productList.Products != null) 36 { 37 foreach (var p in productList.Products) { dummyProductId = p.Id; } 38 ProductViewModel dummyProduct = dummyProductId != "" ? ViewModelFactory.CreateView(productSetting, dummyProductId) : new ProductViewModel(); 39 product = dummyProduct; 40 } 41 else 42 { 43 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetAllProducts(Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 44 } 45 } 46 else if (Pageview.Item["DummyProduct"] == null) 47 { 48 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetAllProducts(Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 49 } 50 51 string fullWidth = Model.Item.GetRawValueString("HorizontalAlignment", "") == "full" ? "w-100" : ""; 52 string horizontalAlign = Model.Item.GetRawValueString("HorizontalAlignment", ""); 53 horizontalAlign = horizontalAlign == "center" ? "justify-content-center" : horizontalAlign; 54 horizontalAlign = horizontalAlign == "end" ? "justify-content-end" : horizontalAlign; 55 horizontalAlign = horizontalAlign == "full" ? "" : horizontalAlign; 56 57 string anonymousUsersLimitations = Pageview.AreaSettings.GetRawValueString("AnonymousUsers", ""); 58 bool anonymousUser = Pageview.User == null; 59 bool hideAddToCart = anonymousUsersLimitations.Contains("cart") && anonymousUser; 60 hideAddToCart = product.VariantInfo.VariantInfo != null && Model.Item.GetBoolean("CustomHideVariantSelector") ? true : hideAddToCart; 61 hideAddToCart = product.ProductFields.ContainsKey("Custom_DisablePurchase") ? Convert.ToBoolean(product.ProductFields["Custom_DisablePurchase"].Value) : hideAddToCart; //CUSTOM 62 bool hidePrice = anonymousUsersLimitations.Contains("price") && anonymousUser; 63 bool hideFavoritesSelector = !string.IsNullOrEmpty(Model.Item.GetString("CustomHideFavoritesSelector")) ? Model.Item.GetBoolean("CustomHideFavoritesSelector") : false; 64 65 var favoriteParameters = new Dictionary<string, object>(); 66 if (!anonymousUser && !hideFavoritesSelector) 67 { 68 IEnumerable<FavoriteList> favoreiteLists = Pageview.User.GetFavoriteLists(); 69 int defaultFavoriteListId = 0; 70 71 if (favoreiteLists.Count() == 1) 72 { 73 foreach (FavoriteList list in favoreiteLists) 74 { 75 defaultFavoriteListId = list.ListId; 76 } 77 } 78 79 favoriteParameters.Add("ListId", defaultFavoriteListId); 80 } 81 } 82 83 @if (!hideAddToCart && product.Id != null) 84 { 85 string url = "/Default.aspx?ID=" + (GetPageIdByNavigationTag("CartService")); 86 if (!url.Contains("LayoutTemplate")) 87 { 88 url += url.Contains("?") ? "&LayoutTemplate=Swift_MiniCart.cshtml" : "?LayoutTemplate=Swift_MiniCart.cshtml"; 89 } 90 91 var productSpecificationService = ObjectFactory.GetInstance<IProductSpecificationService>(); 92 var productSpecs = productSpecificationService.GetProductSpecifications(product.GetAutoId()); 93 94 string flexFill = Model.Item.GetRawValueString("HorizontalAlignment", "") == "full" ? "flex-fill" : ""; 95 96 string minQty = product.PurchaseMinimumQuantity != 1 ? "min=\"" + product.PurchaseMinimumQuantity.ToString() + "\"" : "min=\"1\""; 97 string stepQty = product.PurchaseQuantityStep > 1 ? product.PurchaseQuantityStep.ToString() : "1"; 98 string valueQty = product.PurchaseMinimumQuantity > product.PurchaseQuantityStep ? product.PurchaseMinimumQuantity.ToString() : stepQty; 99 string qtyValidCheck = stepQty != "1" ? "onkeyup=\"swift.Cart.QuantityValidate(event)\"" : ""; 100 101 string showPricesWithVat = HttpContext.Current.Session["Smartpage:ShowPricesWithVat"] != null ? Convert.ToString(HttpContext.Current.Session["Smartpage:ShowPricesWithVat"]) : Pageview.Area.EcomPricesWithVat.ToLower(); 102 bool neverShowVat = string.IsNullOrEmpty(showPricesWithVat); 103 104 <div class="d-flex @horizontalAlign @fullWidth item_@Model.Item.SystemName.ToLower()"> 105 <form method="post" action="@url" class="@fullWidth"> 106 <input type="hidden" name="redirect" value="false" /> 107 <input type="hidden" name="ProductId" value="@product.Id" /> 108 <input type="hidden" name="ProductName" value="@HtmlEncoder.HtmlEncode(product.Name)" /> 109 <input type="hidden" name="ProductVariantName" value="@HtmlEncoder.HtmlEncode(product.VariantName)" /> 110 <input type="hidden" name="ProductCurrency" value="@productSetting.CurrencyCode" /> 111 <input type="hidden" name="ProductPrice" value="@(showPricesWithVat == "false" && !neverShowVat ? product.Price.PriceWithoutVat.ToString("0.00", CultureInfo.InvariantCulture) : product.Price.Price.ToString("0.00", CultureInfo.InvariantCulture))" /> 112 <input type="hidden" name="ProductReferer" value="component_ProductAddToCart_Custom"> 113 <input type="hidden" name="cartcmd" value="add" /> 114 115 <input type="hidden" class="js-product-id" value="@product.Id" /> 116 117 @if (!string.IsNullOrEmpty(product.VariantId)) 118 { 119 <input type="hidden" name="VariantId" value="@product.VariantId" /> 120 } 121 @if (!Model.Item.GetBoolean("CustomUseQuantitySelector")) 122 { 123 <input id="Quantity_@product.Id" name="Quantity" value="@valueQty" type="hidden"> 124 125 if (!productSpecs.GetByKey("Preorder").Value.IsYes()) 126 { 127 <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> 128 } 129 else 130 { 131 <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"> 132 @Translate("Preorder") 133 </button> 134 } 135 } 136 else 137 { 138 <div class="input-group input-primary-button-group js-input-group d-flex flex-row flex-nowrap"> 139 <label for="Quantity_@(product.Id)" class="visually-hidden">@Translate("Quantity")</label> 140 <input id="Quantity_@product.Id" name="Quantity" value="@valueQty" step="@stepQty" @minQty class="form-control" style="max-width: 96px; min-width:64px;" type="number"> 141 <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> 142 </div> 143 144 if (stepQty != "1") 145 { 146 <div class="invalid-feedback d-none"> 147 @Translate("Please select a quantity that is dividable by") @stepQty 148 </div> 149 } 150 } 151 </form> 152 @if (!anonymousUser && !hideFavoritesSelector) 153 { 154 @RenderPartial("Components/ToggleFavorite.cshtml", product, favoriteParameters) 155 } 156 </div> 157 } 158 else if (!anonymousUser && !hideFavoritesSelector) 159 { 160 <div class="d-flex @horizontalAlign @fullWidth item_@Model.Item.SystemName.ToLower()"> 161 <div class="flex-fill"> 162 @Translate("Add to favorites") @RenderPartial("Components/ToggleFavorite.cshtml", product, favoriteParameters) 163 </div> 164 </div> 165 } 166 else if (Pageview.IsVisualEditorMode) 167 { 168 <div class="alert alert-dark m-0">@Translate("No products available")</div> 169 } 170
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_ad113c399efd46d3aa35996c3127f7c9.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 var defaultOnlineStockLocationId = Model.Item.GetRawValueString("CustomDefaultStockLocation"); 53 54 //Custom: Build unified list of stock locations to display 55 var displayLocations = new List<(string Name, double Qty, bool IsDefault)>(); 56 57 //Custom: Check if default online stock location exists in the list 58 var hasDefaultLocation = !string.IsNullOrEmpty(defaultOnlineStockLocationId) && 59 stockLocations.Any(sl => sl.StockLocationId.ToString() == defaultOnlineStockLocationId); 60 61 //Custom: Add default online location first if not in the stock list 62 if (!string.IsNullOrEmpty(defaultOnlineStockLocationId) && !hasDefaultLocation) 63 { 64 var defaultOnlineStockLocation = Dynamicweb.Ecommerce.Services.StockService.GetStockLocation(Convert.ToInt32(defaultOnlineStockLocationId)); 65 var totalQty = stockLocations.Sum(sl => sl.StockLevel); 66 var defaultLocationName = defaultOnlineStockLocation.Name; 67 displayLocations.Add((defaultLocationName, totalQty, true)); 68 } 69 70 //Custom: Add existing stock locations 71 foreach (var stockLocation in stockLocations.OrderByDescending(location => defaultOnlineStockLocationId == location.StockLocationId.ToString())) 72 { 73 var locationName = stockLocation.StockLocationName; 74 var qty = stockLocation.StockLevel; 75 var isDefault = !string.IsNullOrEmpty(defaultOnlineStockLocationId) && 76 defaultOnlineStockLocationId == stockLocation.StockLocationId.ToString(); 77 78 //Custom: Sum inventory for all locations if online stock location 79 if (isDefault) 80 { 81 qty = stockLocations.Sum(sl => sl.StockLevel); 82 } 83 84 displayLocations.Add((locationName, qty, isDefault)); 85 } 86 87 <div class="mt-3 js-stock-state d-flex flex-column gap-2"> 88 <ul class="list-group"> 89 @foreach (var location in displayLocations) 90 { 91 <li class="list-group-item"> 92 <div class="product-stock-item d-flex justify-content-between"> 93 <span class="product-stock-location fs-7"> 94 @location.Name 95 </span> 96 <span class="product-stock-status fs-7"> 97 <span class="icon-stock @(location.Qty > 0 ? "icon-green" : "icon-red") position-relative"></span> 98 @(location.Qty > 0 ? Translate("label_in_Stock", "På lager") : Translate("label_not_in_stock", "Ikke på lager")) 99 </span> 100 </div> 101 </li> 102 } 103 </ul> 104 </div> 105 } 106 } 107 }
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_6a295c8dd8b948db8b7c4f2942e99f5c.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 else if (Pageview.IsVisualEditorMode) 105 { 106 <div class="alert alert-dark m-0">@Translate("Campaign info will be displayed here")</div> 107 } 108 } 109
Error executing template "Designs/Swift/Paragraph/CustomTradeIn.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_0291914f722b46b890ebac787954367d.Execute() in C:\inetpub\solutions\Goecker-2022-Prod\Files\Templates\Designs\Swift\Paragraph\CustomTradeIn.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 @using NLWI.Core.Factory 4 @using NORRIQ.CustomCode.Razor 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 44 @if (product is object) 45 { 46 var specs = product.GetSpecifications(); 47 48 if (specs.GetByKey("LoopiaDisplayTradeInLink")?.Value == "true" || Pageview.IsVisualEditorMode) 49 { 50 string theme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Theme")) ? " theme " + Model.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : string.Empty; 51 var header = Model.Item.GetRawValueString("Header"); 52 var text = Model.Item.GetRawValueString("Text"); 53 var link = Model.Item.GetLink("Link"); 54 var linkText = Model.Item.GetRawValueString("LinkText"); 55 56 <div class="accordion mt-3 @theme" id="accordion"> 57 <div class="accordion-item"> 58 59 <h2 class="accordion-header" id="headingOne"> 60 <button class="accordion-button fw-bold collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapseTrade" aria-expanded="true" aria-controls="collapseOne"> 61 @header 62 </button> 63 </h2> 64 65 <div id="collapseTrade" class="accordion-collapse collapse" aria-labelledby="headingOne" data-bs-parent="#accordion"> 66 <div class="accordion-body d-flex justify-content-between flex-wrap"> 67 <div class="p-2 fs-7"> 68 @text 69 <p> 70 <strong><a href="@(link?.Url + product.Number)">@linkText</a></strong> 71 </p> 72 </div> 73 </div> 74 </div> 75 </div> 76 </div> 77 } 78 } 79 else if (Pageview.IsVisualEditorMode) 80 { 81 <div class="alert alert-dark m-0">@Translate("Trade-in box will be displayed here")</div> 82 } 83
Error executing template "/Designs/Swift/Paragraph/Swift_ProductDetailsAccordion_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_00060f3cc30f4c3e9108ca88e226edc0.Execute() in C:\inetpub\solutions\Goecker-2022-Prod\Files\Templates\Designs\Swift\Paragraph\Swift_ProductDetailsAccordion_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.CountryCode; 51 string iconPath = "/Files/Templates/Designs/Swift/Assets/icons/"; 52 53 <div class="accordion mt-3" id="accordion"> 54 @if (specs.GetAllByKey("Produktekspert" + featurePostFix).Any() && !Model.Item.GetBoolean("HideProductExperts")) 55 { 56 <div class="accordion-item"> 57 58 <h2 class="accordion-header" id="headingOne"> 59 <button class="accordion-button fw-bold collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapseOne" aria-expanded="false" aria-controls="collapseOne"> 60 <img src="@(iconPath)users.svg" class="me-2" /> 61 @Translate("Smartpage:Product.Details.Product experts", "Produkteksperter") 62 </button> 63 </h2> 64 65 <div id="collapseOne" class="accordion-collapse collapse" aria-labelledby="headingOne" data-bs-parent="#accordion"> 66 <div class="accordion-body d-flex justify-content-between flex-wrap flex-column"> 67 68 69 @foreach (var expert in specs.GetAllByKey("Produktekspert" + featurePostFix)) 70 { 71 var referenceSpecfication = expert.GetReferenceSpecification(); 72 73 var image = "~/Files/Images/missing_image.jpg"; 74 foreach (var test in referenceSpecfication.GetAllAvailableKeys()) 75 { 76 if (referenceSpecfication.GetByKey(test).Value.Contains("Images/Perfion")) 77 { 78 image = referenceSpecfication.GetByKey(test).Value; 79 } 80 } 81 <div class="expert-container d-flex"> 82 <img src="/Admin/Public/GetImage.ashx?Image=@image&Width=60&Height=60&Crop=5&Compression=85" width="60" height="60" /> 83 <div class="info ms-2 fs-7"> 84 <strong>@referenceSpecfication.GetByKey("Value").Value</strong><br /> 85 <a href="mailto:@referenceSpecfication.GetByKey("Email").Value" class="link-primary">@referenceSpecfication.GetByKey("Email").Value</a><br /> 86 <span class="icon-phone"></span> 87 @referenceSpecfication.GetByKey("Telefonnr").Value<br /> 88 @if (referenceSpecfication.HasKey("Lokation")) 89 { 90 <span class="icon-map"></span> 91 @referenceSpecfication.GetByKey("Lokation").Value 92 }<br /><br /> 93 </div> 94 </div> 95 } 96 </div> 97 </div> 98 </div> 99 } 100 101 @if (specs.GetAllByKey("PDFbrochure").Any()) 102 { 103 <div class="accordion-item"> 104 105 <h2 class="accordion-header" id="headingTwo"> 106 <button class="accordion-button collapsed fw-bold" type="button" data-bs-toggle="collapse" data-bs-target="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo"> 107 <img src="@(iconPath)file.svg" class="me-2" /> 108 @Translate("Brochurer og tech. Info") 109 </button> 110 </h2> 111 112 <div id="collapseTwo" class="accordion-collapse collapse" aria-labelledby="headingTwo" data-bs-parent="#accordion"> 113 <div class="accordion-body d-flex flex-column justify-content-between flex-wrap gap-2"> 114 @foreach (var pdfbrochure in specs.GetAllByKey("PDFbrochure")) 115 { 116 <div class="d-flex align-items-center"> 117 <img src="@(iconPath)file.svg" class="me-2" /> 118 <a href="@(pdfbrochure.Value)" class="text-decoration-none" target="_blank"> 119 @Translate("Produkt brochure") 120 </a> 121 </div> 122 } 123 @foreach (var pdfmanual in specs.GetAllByKey("PDFmanual")) 124 { 125 <div class="d-flex align-items-center"> 126 <img src="@(iconPath)file.svg" class="me-2" /> 127 <a href="@(pdfmanual.Value)" class="text-decoration-none" target="_blank"> 128 @Translate("Produkt manual") 129 </a> 130 </div> 131 } 132 @foreach (var pdfbrochure in specs.GetAllByKey("PDFreview")) 133 { 134 <div class="d-flex align-items-center"> 135 <img src="@(iconPath)file.svg" class="me-2" /> 136 <a href="@(pdfbrochure.Value)" class="text-decoration-none" target="_blank"> 137 @Translate("Produkt review") 138 </a> 139 </div> 140 } 141 </div> 142 </div> 143 </div> 144 } 145 146 147 @if (!Model.Item.GetBoolean("HideFactSheetLink")) 148 { 149 string sheetId = Model.Item.GetString("PerfionDatasheetId"); 150 151 <div class="accordion-item"> 152 <h2 class="accordion-header" id="headingTwo"> 153 <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"> 154 <img src="@(iconPath)download.svg" class="me-2" /> 155 @Translate("Smartpage:Product.Details.Printable fact sheet", "Printbar fakta side") 156 </button> 157 </h2> 158 </div> 159 } 160 </div> 161 }
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_1f60358fec5c4017b55bb611eb76f23c.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_e498d937c268497eafe537fc9e27820a.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().Where(key => key != "ProduktLoopiaKategori")) 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 }
Sorry. There is nothing to view here