Error executing template "Designs/Swift-v2/Paragraph/Swift-v2_ProductCatalogDetailsApp.cshtml" System.NullReferenceException: Object reference not set to an instance of an object. at CompiledRazorTemplates.Dynamic.RazorEngine_0f405311b4344f56a9b33abff84efc76.ExecuteAsync() at RazorEngine.Templating.TemplateBase.Run(ExecuteContext context, TextWriter reader) at RazorEngine.Templating.RazorEngineCore.RunTemplate(ICompiledTemplate template, TextWriter writer, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.DynamicWrapperService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass23_0.<Run>b__0(TextWriter writer) at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter) at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, Type modelType, Object model, DynamicViewBag viewBag) at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template) in /_/src/Application/Providers/Dynamicweb.Rendering.Providers.NetCore/Razor/RazorTemplateRenderingProvider.cs:line 68 at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template) in E:\dw10agent\_w\2\s\src\Core\Dynamicweb.Core\Rendering\TemplateRenderingService.cs:line 14 at Dynamicweb.Rendering.Template.RenderRazorTemplate() in E:\dw10agent\_w\2\s\src\Core\Dynamicweb.Core\Rendering\Template.cs:line 847
1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using Dynamicweb.Ecommerce.ProductCatalog 3 4 @{ 5 //Set default product data for use in Visual Editor 6 if (Pageview.IsVisualEditorMode) 7 { 8 ProductViewModelSettings productSetting = new ProductViewModelSettings 9 { 10 LanguageId = Dynamicweb.Ecommerce.Common.Context.LanguageID, 11 CurrencyCode = Dynamicweb.Ecommerce.Common.Context.Currency.Code, 12 CountryCode = Dynamicweb.Ecommerce.Common.Context.Country.Code2, 13 ShopId = Pageview.Area.EcomShopId 14 }; 15 } 16 else if (!Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 17 { 18 ProductViewModel product = new ProductViewModel(); 19 Dynamicweb.Context.Current.Items.Add("ProductDetails", product); 20 } 21 } 22 23 @if (Pageview.IsVisualEditorMode) 24 { 25 <div class="alert alert-info" role="alert"> 26 <span>@Translate("Product catalog App: Edit this column to configure. (Product catalog app must be attached this paragraph)")</span> 27 </div> 28 } 29 30 <div class="item_@Model.Item.SystemName.ToLower()"> 31 @Model.GetModuleOutput() 32 </div> 33
Error executing template "Designs/Swift-v2/Paragraph/Swift-v2_BackInStockNotification.cshtml" System.NullReferenceException: Object reference not set to an instance of an object. at CompiledRazorTemplates.Dynamic.RazorEngine_a93a630c5e82497fb08a36f78035f9f5.ExecuteAsync() at RazorEngine.Templating.TemplateBase.Run(ExecuteContext context, TextWriter reader) at RazorEngine.Templating.RazorEngineCore.RunTemplate(ICompiledTemplate template, TextWriter writer, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.DynamicWrapperService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass23_0.<Run>b__0(TextWriter writer) at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter) at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, Type modelType, Object model, DynamicViewBag viewBag) at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template) in /_/src/Application/Providers/Dynamicweb.Rendering.Providers.NetCore/Razor/RazorTemplateRenderingProvider.cs:line 68 at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template) in E:\dw10agent\_w\2\s\src\Core\Dynamicweb.Core\Rendering\TemplateRenderingService.cs:line 14 at Dynamicweb.Rendering.Template.RenderRazorTemplate() in E:\dw10agent\_w\2\s\src\Core\Dynamicweb.Core\Rendering\Template.cs:line 847
1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using System.Linq 3 @using Dynamicweb.Ecommerce 4 @using Dynamicweb.Ecommerce.ProductCatalog 5 @using Dynamicweb.Ecommerce.Products 6 @using Dynamicweb.Ecommerce.Stocks 7 8 @functions 9 { 10 private static bool BackInStockRegisteredForUser(ProductViewModel product, string unitId = "", long stocklocationId = 0) 11 { 12 if (!Dynamicweb.Security.UserManagement.User.IsExtranetUserLoggedIn()) return false; 13 14 Product productObject = Services.Products.GetProductById(product.Id, product.VariantId, product.LanguageId); 15 StockLocation stockLocation = Services.StockService.GetStockLocation(stocklocationId); 16 double unitStock = productObject.GetUnitStock(stockLocation, unitId); 17 return unitStock <= 0d && ProductBackInStockNotification.BackInStockNotificationExists(productObject, unitId); 18 } 19 } 20 21 @{ 22 ProductViewModel product = null; 23 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 24 { 25 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 26 } 27 } 28 29 @if ((product is object && product.ProductType == Dynamicweb.Ecommerce.Products.ProductType.Stock)) 30 { 31 bool productInStock = product.StockLevel > 0 || product.NeverOutOfstock; 32 33 if (!productInStock) 34 { 35 string notifiedMessage = Model.Item.GetString("NotifiedMessage"); 36 string notifiedMessageId = $"NotifiedMessage_item_{Model.Item.SystemName.ToLower()}_{product.Id}_{product.VariantId.Replace(".", "_")}"; 37 38 string horizontalAlign = Model.Item.GetRawValueString("HorizontalAlignment", ""); 39 horizontalAlign = horizontalAlign == "center" ? "justify-content-center" : horizontalAlign; 40 horizontalAlign = horizontalAlign == "end" ? "justify-content-end" : horizontalAlign; 41 horizontalAlign = horizontalAlign == "full" ? "" : horizontalAlign; 42 43 string flexFill = Model.Item.GetRawValueString("HorizontalAlignment", "") == "full" ? "flex-fill" : ""; 44 string fullWidth = Model.Item.GetRawValueString("HorizontalAlignment", "") == "full" ? "w-100" : ""; 45 46 bool notificationRegisteredForUser = BackInStockRegisteredForUser(product); 47 48 <div class="d-flex flex-row w-100 @horizontalAlign @fullWidth item_@Model.Item.SystemName.ToLower()"> 49 <div class="@horizontalAlign @fullWidth @(notificationRegisteredForUser ? "" : "d-none")" id="@notifiedMessageId"> 50 @notifiedMessage 51 </div> 52 53 @if (!notificationRegisteredForUser) 54 { 55 56 string notifyIcon = Model.Item.GetString("Icon"); 57 string notifyLabel = !notifyIcon.Contains("_none") ? "<span class=\"icon-2\">" + ReadFile(notifyIcon) + "</span>" : ""; 58 notifyLabel += " " + Translate("Notify me when available"); 59 60 string modalId = $"modal_item_{Model.Item.SystemName.ToLower()}_{product.Id}_{product.VariantId.Replace(".", "_")}"; 61 string formId = $"NotificationForm_item_{Model.Item.SystemName.ToLower()}_{product.Id}_{product.VariantId.Replace(".", "_")}"; 62 string notificationButtonId = $"NotificationButton_item_{Model.Item.SystemName.ToLower()}_{product.Id}_{product.VariantId.Replace(".", "_")}"; 63 string notificationOnClick = !Pageview.IsVisualEditorMode ? $"swift.BackInStockNotification.SubmitNotification('{formId}', '{modalId}', '{notifiedMessageId}', '{notificationButtonId}')" : ""; 64 65 string productPage = $"/Default.aspx?ID={GetPageIdByNavigationTag("ProductDetailPage")}"; 66 67 <div class="d-flex @horizontalAlign @fullWidth js-input-group"> 68 <div class="input-group input-primary-button-group flex-nowrap"> 69 <button type="button" class="btn btn-primary @flexFill" data-dw-button="primary" id="@notificationButtonId" data-bs-toggle="modal" data-bs-target="#@modalId"> 70 <span class="text-nowrap d-flex align-items-center justify-content-center gap-2"> 71 @notifyLabel 72 </span> 73 </button> 74 </div> 75 </div> 76 77 <div class="modal fade" id="@modalId" tabindex="-1" aria-labelledby="label_@modalId" aria-hidden="true"> 78 <div class="modal-dialog pt-8"> 79 <div class="modal-content"> 80 <div class="modal-header"> 81 <h5 class="modal-title" id="label_@modalId">@Translate("Back in stock")</h5> 82 <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="@Translate("Close")"></button> 83 </div> 84 <div class="modal-body"> 85 <form name="@product.Id" id="@formId" method="post" action="@productPage"> 86 <input type="hidden" name="ProductID" value="@product.Id" /> 87 <input type="hidden" name="VariantID" value="@product.VariantId" /> 88 <input type="hidden" name="LanguageID" value="@product.LanguageId" /> 89 <input type="hidden" name="CartCmd" value="createnotificationforthisproduct" /> 90 <div class="m-2"> 91 @Translate("Send me an email when the product is in stock.") 92 </div> 93 <div class="form-floating m-2"> 94 <input class="form-control" type="text" id="NotificationEmail" value="@(Pageview.User != null ? Pageview.User.Email : "")" name="NotificationEmail" placeholder="@Translate("Email")" required="required" aria-required="aria-required" /> 95 <label for="NotificationEmail" class="form-label">@Translate("Email")</label> 96 </div> 97 </form> 98 </div> 99 <div class="modal-footer"> 100 <button type="button" class="btn btn-primary" data-dw-button="primary" onclick="@notificationOnClick">@Translate("Submit")</button> 101 </div> 102 </div> 103 </div> 104 </div> 105 } 106 </div> 107 } 108 } 109 else if (Pageview.IsVisualEditorMode) 110 { 111 <div class="alert alert-dark m-0">@Translate("Back in stock notification will be shown here")</div> 112 } 113
Error executing template "Designs/Swift-v2/Paragraph/Swift-v2_BackInStockNotification.cshtml" System.NullReferenceException: Object reference not set to an instance of an object. at CompiledRazorTemplates.Dynamic.RazorEngine_a93a630c5e82497fb08a36f78035f9f5.ExecuteAsync() at RazorEngine.Templating.TemplateBase.Run(ExecuteContext context, TextWriter reader) at RazorEngine.Templating.RazorEngineCore.RunTemplate(ICompiledTemplate template, TextWriter writer, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.DynamicWrapperService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass23_0.<Run>b__0(TextWriter writer) at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter) at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, Type modelType, Object model, DynamicViewBag viewBag) at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template) in /_/src/Application/Providers/Dynamicweb.Rendering.Providers.NetCore/Razor/RazorTemplateRenderingProvider.cs:line 68 at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template) in E:\dw10agent\_w\2\s\src\Core\Dynamicweb.Core\Rendering\TemplateRenderingService.cs:line 14 at Dynamicweb.Rendering.Template.RenderRazorTemplate() in E:\dw10agent\_w\2\s\src\Core\Dynamicweb.Core\Rendering\Template.cs:line 847
1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using System.Linq 3 @using Dynamicweb.Ecommerce 4 @using Dynamicweb.Ecommerce.ProductCatalog 5 @using Dynamicweb.Ecommerce.Products 6 @using Dynamicweb.Ecommerce.Stocks 7 8 @functions 9 { 10 private static bool BackInStockRegisteredForUser(ProductViewModel product, string unitId = "", long stocklocationId = 0) 11 { 12 if (!Dynamicweb.Security.UserManagement.User.IsExtranetUserLoggedIn()) return false; 13 14 Product productObject = Services.Products.GetProductById(product.Id, product.VariantId, product.LanguageId); 15 StockLocation stockLocation = Services.StockService.GetStockLocation(stocklocationId); 16 double unitStock = productObject.GetUnitStock(stockLocation, unitId); 17 return unitStock <= 0d && ProductBackInStockNotification.BackInStockNotificationExists(productObject, unitId); 18 } 19 } 20 21 @{ 22 ProductViewModel product = null; 23 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 24 { 25 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 26 } 27 } 28 29 @if ((product is object && product.ProductType == Dynamicweb.Ecommerce.Products.ProductType.Stock)) 30 { 31 bool productInStock = product.StockLevel > 0 || product.NeverOutOfstock; 32 33 if (!productInStock) 34 { 35 string notifiedMessage = Model.Item.GetString("NotifiedMessage"); 36 string notifiedMessageId = $"NotifiedMessage_item_{Model.Item.SystemName.ToLower()}_{product.Id}_{product.VariantId.Replace(".", "_")}"; 37 38 string horizontalAlign = Model.Item.GetRawValueString("HorizontalAlignment", ""); 39 horizontalAlign = horizontalAlign == "center" ? "justify-content-center" : horizontalAlign; 40 horizontalAlign = horizontalAlign == "end" ? "justify-content-end" : horizontalAlign; 41 horizontalAlign = horizontalAlign == "full" ? "" : horizontalAlign; 42 43 string flexFill = Model.Item.GetRawValueString("HorizontalAlignment", "") == "full" ? "flex-fill" : ""; 44 string fullWidth = Model.Item.GetRawValueString("HorizontalAlignment", "") == "full" ? "w-100" : ""; 45 46 bool notificationRegisteredForUser = BackInStockRegisteredForUser(product); 47 48 <div class="d-flex flex-row w-100 @horizontalAlign @fullWidth item_@Model.Item.SystemName.ToLower()"> 49 <div class="@horizontalAlign @fullWidth @(notificationRegisteredForUser ? "" : "d-none")" id="@notifiedMessageId"> 50 @notifiedMessage 51 </div> 52 53 @if (!notificationRegisteredForUser) 54 { 55 56 string notifyIcon = Model.Item.GetString("Icon"); 57 string notifyLabel = !notifyIcon.Contains("_none") ? "<span class=\"icon-2\">" + ReadFile(notifyIcon) + "</span>" : ""; 58 notifyLabel += " " + Translate("Notify me when available"); 59 60 string modalId = $"modal_item_{Model.Item.SystemName.ToLower()}_{product.Id}_{product.VariantId.Replace(".", "_")}"; 61 string formId = $"NotificationForm_item_{Model.Item.SystemName.ToLower()}_{product.Id}_{product.VariantId.Replace(".", "_")}"; 62 string notificationButtonId = $"NotificationButton_item_{Model.Item.SystemName.ToLower()}_{product.Id}_{product.VariantId.Replace(".", "_")}"; 63 string notificationOnClick = !Pageview.IsVisualEditorMode ? $"swift.BackInStockNotification.SubmitNotification('{formId}', '{modalId}', '{notifiedMessageId}', '{notificationButtonId}')" : ""; 64 65 string productPage = $"/Default.aspx?ID={GetPageIdByNavigationTag("ProductDetailPage")}"; 66 67 <div class="d-flex @horizontalAlign @fullWidth js-input-group"> 68 <div class="input-group input-primary-button-group flex-nowrap"> 69 <button type="button" class="btn btn-primary @flexFill" data-dw-button="primary" id="@notificationButtonId" data-bs-toggle="modal" data-bs-target="#@modalId"> 70 <span class="text-nowrap d-flex align-items-center justify-content-center gap-2"> 71 @notifyLabel 72 </span> 73 </button> 74 </div> 75 </div> 76 77 <div class="modal fade" id="@modalId" tabindex="-1" aria-labelledby="label_@modalId" aria-hidden="true"> 78 <div class="modal-dialog pt-8"> 79 <div class="modal-content"> 80 <div class="modal-header"> 81 <h5 class="modal-title" id="label_@modalId">@Translate("Back in stock")</h5> 82 <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="@Translate("Close")"></button> 83 </div> 84 <div class="modal-body"> 85 <form name="@product.Id" id="@formId" method="post" action="@productPage"> 86 <input type="hidden" name="ProductID" value="@product.Id" /> 87 <input type="hidden" name="VariantID" value="@product.VariantId" /> 88 <input type="hidden" name="LanguageID" value="@product.LanguageId" /> 89 <input type="hidden" name="CartCmd" value="createnotificationforthisproduct" /> 90 <div class="m-2"> 91 @Translate("Send me an email when the product is in stock.") 92 </div> 93 <div class="form-floating m-2"> 94 <input class="form-control" type="text" id="NotificationEmail" value="@(Pageview.User != null ? Pageview.User.Email : "")" name="NotificationEmail" placeholder="@Translate("Email")" required="required" aria-required="aria-required" /> 95 <label for="NotificationEmail" class="form-label">@Translate("Email")</label> 96 </div> 97 </form> 98 </div> 99 <div class="modal-footer"> 100 <button type="button" class="btn btn-primary" data-dw-button="primary" onclick="@notificationOnClick">@Translate("Submit")</button> 101 </div> 102 </div> 103 </div> 104 </div> 105 } 106 </div> 107 } 108 } 109 else if (Pageview.IsVisualEditorMode) 110 { 111 <div class="alert alert-dark m-0">@Translate("Back in stock notification will be shown here")</div> 112 } 113
Error executing template "Designs/Swift-v2/Paragraph/Swift-v2_BackInStockNotification.cshtml" System.NullReferenceException: Object reference not set to an instance of an object. at CompiledRazorTemplates.Dynamic.RazorEngine_a93a630c5e82497fb08a36f78035f9f5.ExecuteAsync() at RazorEngine.Templating.TemplateBase.Run(ExecuteContext context, TextWriter reader) at RazorEngine.Templating.RazorEngineCore.RunTemplate(ICompiledTemplate template, TextWriter writer, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.DynamicWrapperService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass23_0.<Run>b__0(TextWriter writer) at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter) at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, Type modelType, Object model, DynamicViewBag viewBag) at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template) in /_/src/Application/Providers/Dynamicweb.Rendering.Providers.NetCore/Razor/RazorTemplateRenderingProvider.cs:line 68 at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template) in E:\dw10agent\_w\2\s\src\Core\Dynamicweb.Core\Rendering\TemplateRenderingService.cs:line 14 at Dynamicweb.Rendering.Template.RenderRazorTemplate() in E:\dw10agent\_w\2\s\src\Core\Dynamicweb.Core\Rendering\Template.cs:line 847
1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using System.Linq 3 @using Dynamicweb.Ecommerce 4 @using Dynamicweb.Ecommerce.ProductCatalog 5 @using Dynamicweb.Ecommerce.Products 6 @using Dynamicweb.Ecommerce.Stocks 7 8 @functions 9 { 10 private static bool BackInStockRegisteredForUser(ProductViewModel product, string unitId = "", long stocklocationId = 0) 11 { 12 if (!Dynamicweb.Security.UserManagement.User.IsExtranetUserLoggedIn()) return false; 13 14 Product productObject = Services.Products.GetProductById(product.Id, product.VariantId, product.LanguageId); 15 StockLocation stockLocation = Services.StockService.GetStockLocation(stocklocationId); 16 double unitStock = productObject.GetUnitStock(stockLocation, unitId); 17 return unitStock <= 0d && ProductBackInStockNotification.BackInStockNotificationExists(productObject, unitId); 18 } 19 } 20 21 @{ 22 ProductViewModel product = null; 23 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 24 { 25 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 26 } 27 } 28 29 @if ((product is object && product.ProductType == Dynamicweb.Ecommerce.Products.ProductType.Stock)) 30 { 31 bool productInStock = product.StockLevel > 0 || product.NeverOutOfstock; 32 33 if (!productInStock) 34 { 35 string notifiedMessage = Model.Item.GetString("NotifiedMessage"); 36 string notifiedMessageId = $"NotifiedMessage_item_{Model.Item.SystemName.ToLower()}_{product.Id}_{product.VariantId.Replace(".", "_")}"; 37 38 string horizontalAlign = Model.Item.GetRawValueString("HorizontalAlignment", ""); 39 horizontalAlign = horizontalAlign == "center" ? "justify-content-center" : horizontalAlign; 40 horizontalAlign = horizontalAlign == "end" ? "justify-content-end" : horizontalAlign; 41 horizontalAlign = horizontalAlign == "full" ? "" : horizontalAlign; 42 43 string flexFill = Model.Item.GetRawValueString("HorizontalAlignment", "") == "full" ? "flex-fill" : ""; 44 string fullWidth = Model.Item.GetRawValueString("HorizontalAlignment", "") == "full" ? "w-100" : ""; 45 46 bool notificationRegisteredForUser = BackInStockRegisteredForUser(product); 47 48 <div class="d-flex flex-row w-100 @horizontalAlign @fullWidth item_@Model.Item.SystemName.ToLower()"> 49 <div class="@horizontalAlign @fullWidth @(notificationRegisteredForUser ? "" : "d-none")" id="@notifiedMessageId"> 50 @notifiedMessage 51 </div> 52 53 @if (!notificationRegisteredForUser) 54 { 55 56 string notifyIcon = Model.Item.GetString("Icon"); 57 string notifyLabel = !notifyIcon.Contains("_none") ? "<span class=\"icon-2\">" + ReadFile(notifyIcon) + "</span>" : ""; 58 notifyLabel += " " + Translate("Notify me when available"); 59 60 string modalId = $"modal_item_{Model.Item.SystemName.ToLower()}_{product.Id}_{product.VariantId.Replace(".", "_")}"; 61 string formId = $"NotificationForm_item_{Model.Item.SystemName.ToLower()}_{product.Id}_{product.VariantId.Replace(".", "_")}"; 62 string notificationButtonId = $"NotificationButton_item_{Model.Item.SystemName.ToLower()}_{product.Id}_{product.VariantId.Replace(".", "_")}"; 63 string notificationOnClick = !Pageview.IsVisualEditorMode ? $"swift.BackInStockNotification.SubmitNotification('{formId}', '{modalId}', '{notifiedMessageId}', '{notificationButtonId}')" : ""; 64 65 string productPage = $"/Default.aspx?ID={GetPageIdByNavigationTag("ProductDetailPage")}"; 66 67 <div class="d-flex @horizontalAlign @fullWidth js-input-group"> 68 <div class="input-group input-primary-button-group flex-nowrap"> 69 <button type="button" class="btn btn-primary @flexFill" data-dw-button="primary" id="@notificationButtonId" data-bs-toggle="modal" data-bs-target="#@modalId"> 70 <span class="text-nowrap d-flex align-items-center justify-content-center gap-2"> 71 @notifyLabel 72 </span> 73 </button> 74 </div> 75 </div> 76 77 <div class="modal fade" id="@modalId" tabindex="-1" aria-labelledby="label_@modalId" aria-hidden="true"> 78 <div class="modal-dialog pt-8"> 79 <div class="modal-content"> 80 <div class="modal-header"> 81 <h5 class="modal-title" id="label_@modalId">@Translate("Back in stock")</h5> 82 <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="@Translate("Close")"></button> 83 </div> 84 <div class="modal-body"> 85 <form name="@product.Id" id="@formId" method="post" action="@productPage"> 86 <input type="hidden" name="ProductID" value="@product.Id" /> 87 <input type="hidden" name="VariantID" value="@product.VariantId" /> 88 <input type="hidden" name="LanguageID" value="@product.LanguageId" /> 89 <input type="hidden" name="CartCmd" value="createnotificationforthisproduct" /> 90 <div class="m-2"> 91 @Translate("Send me an email when the product is in stock.") 92 </div> 93 <div class="form-floating m-2"> 94 <input class="form-control" type="text" id="NotificationEmail" value="@(Pageview.User != null ? Pageview.User.Email : "")" name="NotificationEmail" placeholder="@Translate("Email")" required="required" aria-required="aria-required" /> 95 <label for="NotificationEmail" class="form-label">@Translate("Email")</label> 96 </div> 97 </form> 98 </div> 99 <div class="modal-footer"> 100 <button type="button" class="btn btn-primary" data-dw-button="primary" onclick="@notificationOnClick">@Translate("Submit")</button> 101 </div> 102 </div> 103 </div> 104 </div> 105 } 106 </div> 107 } 108 } 109 else if (Pageview.IsVisualEditorMode) 110 { 111 <div class="alert alert-dark m-0">@Translate("Back in stock notification will be shown here")</div> 112 } 113
Error executing template "Designs/Swift-v2/Paragraph/Swift-v2_BackInStockNotification.cshtml" System.NullReferenceException: Object reference not set to an instance of an object. at CompiledRazorTemplates.Dynamic.RazorEngine_a93a630c5e82497fb08a36f78035f9f5.ExecuteAsync() at RazorEngine.Templating.TemplateBase.Run(ExecuteContext context, TextWriter reader) at RazorEngine.Templating.RazorEngineCore.RunTemplate(ICompiledTemplate template, TextWriter writer, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.DynamicWrapperService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass23_0.<Run>b__0(TextWriter writer) at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter) at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, Type modelType, Object model, DynamicViewBag viewBag) at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template) in /_/src/Application/Providers/Dynamicweb.Rendering.Providers.NetCore/Razor/RazorTemplateRenderingProvider.cs:line 68 at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template) in E:\dw10agent\_w\2\s\src\Core\Dynamicweb.Core\Rendering\TemplateRenderingService.cs:line 14 at Dynamicweb.Rendering.Template.RenderRazorTemplate() in E:\dw10agent\_w\2\s\src\Core\Dynamicweb.Core\Rendering\Template.cs:line 847
1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using System.Linq 3 @using Dynamicweb.Ecommerce 4 @using Dynamicweb.Ecommerce.ProductCatalog 5 @using Dynamicweb.Ecommerce.Products 6 @using Dynamicweb.Ecommerce.Stocks 7 8 @functions 9 { 10 private static bool BackInStockRegisteredForUser(ProductViewModel product, string unitId = "", long stocklocationId = 0) 11 { 12 if (!Dynamicweb.Security.UserManagement.User.IsExtranetUserLoggedIn()) return false; 13 14 Product productObject = Services.Products.GetProductById(product.Id, product.VariantId, product.LanguageId); 15 StockLocation stockLocation = Services.StockService.GetStockLocation(stocklocationId); 16 double unitStock = productObject.GetUnitStock(stockLocation, unitId); 17 return unitStock <= 0d && ProductBackInStockNotification.BackInStockNotificationExists(productObject, unitId); 18 } 19 } 20 21 @{ 22 ProductViewModel product = null; 23 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 24 { 25 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 26 } 27 } 28 29 @if ((product is object && product.ProductType == Dynamicweb.Ecommerce.Products.ProductType.Stock)) 30 { 31 bool productInStock = product.StockLevel > 0 || product.NeverOutOfstock; 32 33 if (!productInStock) 34 { 35 string notifiedMessage = Model.Item.GetString("NotifiedMessage"); 36 string notifiedMessageId = $"NotifiedMessage_item_{Model.Item.SystemName.ToLower()}_{product.Id}_{product.VariantId.Replace(".", "_")}"; 37 38 string horizontalAlign = Model.Item.GetRawValueString("HorizontalAlignment", ""); 39 horizontalAlign = horizontalAlign == "center" ? "justify-content-center" : horizontalAlign; 40 horizontalAlign = horizontalAlign == "end" ? "justify-content-end" : horizontalAlign; 41 horizontalAlign = horizontalAlign == "full" ? "" : horizontalAlign; 42 43 string flexFill = Model.Item.GetRawValueString("HorizontalAlignment", "") == "full" ? "flex-fill" : ""; 44 string fullWidth = Model.Item.GetRawValueString("HorizontalAlignment", "") == "full" ? "w-100" : ""; 45 46 bool notificationRegisteredForUser = BackInStockRegisteredForUser(product); 47 48 <div class="d-flex flex-row w-100 @horizontalAlign @fullWidth item_@Model.Item.SystemName.ToLower()"> 49 <div class="@horizontalAlign @fullWidth @(notificationRegisteredForUser ? "" : "d-none")" id="@notifiedMessageId"> 50 @notifiedMessage 51 </div> 52 53 @if (!notificationRegisteredForUser) 54 { 55 56 string notifyIcon = Model.Item.GetString("Icon"); 57 string notifyLabel = !notifyIcon.Contains("_none") ? "<span class=\"icon-2\">" + ReadFile(notifyIcon) + "</span>" : ""; 58 notifyLabel += " " + Translate("Notify me when available"); 59 60 string modalId = $"modal_item_{Model.Item.SystemName.ToLower()}_{product.Id}_{product.VariantId.Replace(".", "_")}"; 61 string formId = $"NotificationForm_item_{Model.Item.SystemName.ToLower()}_{product.Id}_{product.VariantId.Replace(".", "_")}"; 62 string notificationButtonId = $"NotificationButton_item_{Model.Item.SystemName.ToLower()}_{product.Id}_{product.VariantId.Replace(".", "_")}"; 63 string notificationOnClick = !Pageview.IsVisualEditorMode ? $"swift.BackInStockNotification.SubmitNotification('{formId}', '{modalId}', '{notifiedMessageId}', '{notificationButtonId}')" : ""; 64 65 string productPage = $"/Default.aspx?ID={GetPageIdByNavigationTag("ProductDetailPage")}"; 66 67 <div class="d-flex @horizontalAlign @fullWidth js-input-group"> 68 <div class="input-group input-primary-button-group flex-nowrap"> 69 <button type="button" class="btn btn-primary @flexFill" data-dw-button="primary" id="@notificationButtonId" data-bs-toggle="modal" data-bs-target="#@modalId"> 70 <span class="text-nowrap d-flex align-items-center justify-content-center gap-2"> 71 @notifyLabel 72 </span> 73 </button> 74 </div> 75 </div> 76 77 <div class="modal fade" id="@modalId" tabindex="-1" aria-labelledby="label_@modalId" aria-hidden="true"> 78 <div class="modal-dialog pt-8"> 79 <div class="modal-content"> 80 <div class="modal-header"> 81 <h5 class="modal-title" id="label_@modalId">@Translate("Back in stock")</h5> 82 <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="@Translate("Close")"></button> 83 </div> 84 <div class="modal-body"> 85 <form name="@product.Id" id="@formId" method="post" action="@productPage"> 86 <input type="hidden" name="ProductID" value="@product.Id" /> 87 <input type="hidden" name="VariantID" value="@product.VariantId" /> 88 <input type="hidden" name="LanguageID" value="@product.LanguageId" /> 89 <input type="hidden" name="CartCmd" value="createnotificationforthisproduct" /> 90 <div class="m-2"> 91 @Translate("Send me an email when the product is in stock.") 92 </div> 93 <div class="form-floating m-2"> 94 <input class="form-control" type="text" id="NotificationEmail" value="@(Pageview.User != null ? Pageview.User.Email : "")" name="NotificationEmail" placeholder="@Translate("Email")" required="required" aria-required="aria-required" /> 95 <label for="NotificationEmail" class="form-label">@Translate("Email")</label> 96 </div> 97 </form> 98 </div> 99 <div class="modal-footer"> 100 <button type="button" class="btn btn-primary" data-dw-button="primary" onclick="@notificationOnClick">@Translate("Submit")</button> 101 </div> 102 </div> 103 </div> 104 </div> 105 } 106 </div> 107 } 108 } 109 else if (Pageview.IsVisualEditorMode) 110 { 111 <div class="alert alert-dark m-0">@Translate("Back in stock notification will be shown here")</div> 112 } 113
Error executing template "Designs/Swift-v2/Paragraph/Swift-v2_ProductComponentSlider.cshtml" System.NullReferenceException: Object reference not set to an instance of an object. at CompiledRazorTemplates.Dynamic.RazorEngine_08b7e55b0ffb4de2b6bbd37c4332f9e1.ExecuteAsync() at RazorEngine.Templating.TemplateBase.Run(ExecuteContext context, TextWriter reader) at RazorEngine.Templating.RazorEngineCore.RunTemplate(ICompiledTemplate template, TextWriter writer, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.DynamicWrapperService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass23_0.<Run>b__0(TextWriter writer) at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter) at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, Type modelType, Object model, DynamicViewBag viewBag) at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template) in /_/src/Application/Providers/Dynamicweb.Rendering.Providers.NetCore/Razor/RazorTemplateRenderingProvider.cs:line 68 at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template) in E:\dw10agent\_w\2\s\src\Core\Dynamicweb.Core\Rendering\TemplateRenderingService.cs:line 14 at Dynamicweb.Rendering.Template.RenderRazorTemplate() in E:\dw10agent\_w\2\s\src\Core\Dynamicweb.Core\Rendering\Template.cs:line 847
1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using Dynamicweb.Core 3 @using Dynamicweb.Ecommerce.ProductCatalog 4 5 @{ 6 AddStylesheet("/Files/Templates/Designs/Swift-v2/Assets/lib/swiffy-slider/dist/css/swiffy-slider.css"); 7 8 ProductViewModel product = null; 9 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 10 { 11 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 12 } 13 14 string layout = Model.Item.GetRawValueString("Layout") == "slider" ? "ProductSliderComponent" : "ProductGridComponent"; 15 string lazyHeight = Model.Item.GetBoolean("SetMinHeightForLazyLoading") ? "min-height: 360px" : ""; 16 17 //Link generation 18 string pageId = Model.Item.GetLink("ProductSliderServicePage") != null ? Model.Item.GetLink("ProductSliderServicePage").PageId.ToString() : ""; 19 string servicePageByNavigationTag = GetPageIdByNavigationTag("ProductSliderService") != 0 ? GetPageIdByNavigationTag("ProductSliderService").ToString() : ""; 20 pageId = pageId == "" ? servicePageByNavigationTag : pageId; 21 22 string url = "/Default.aspx?ID=" + pageId; 23 24 if (Pageview.IsVisualEditorMode) 25 { 26 url += "&VisualEdit=True"; 27 } 28 29 url += $"&ProductListPartial={layout}"; //Use this to render either a slider or a grid 30 31 //Source type 32 string sourceType = Model.Item.GetRawValueString("RelationType", "trending"); 33 IList<string> relateFromProductIds = new List<string> { }; 34 IList<string> relateFromProductVariantIds = new List<string> { }; 35 IList<string> relateFromGroupIds = new List<string> { }; 36 bool hasVariants = false; 37 ProductListViewModel relateToViewModel = Model.Item.GetValue<ProductListViewModel>("RelateTo"); 38 39 //--- PRODUCTS --- 40 if (sourceType == "variants" || sourceType == "frequently" || sourceType == "selected") 41 { 42 if (relateToViewModel?.Products != null) 43 { 44 hasVariants = relateToViewModel.Products.Any(p => !string.IsNullOrEmpty(p.VariantId)); 45 foreach (var fromProduct in relateToViewModel.Products) 46 { 47 if (hasVariants) 48 { 49 if (!string.IsNullOrEmpty(fromProduct.VariantId)) 50 { 51 relateFromProductVariantIds.Add($"{fromProduct.Id} {fromProduct.VariantId}"); 52 } 53 else 54 { 55 relateFromProductVariantIds.Add($"{fromProduct.Id}"); 56 } 57 } 58 relateFromProductIds.Add($"{fromProduct.Id}"); 59 } 60 } 61 } 62 63 //--- GROUPS --- 64 if (sourceType == "most-sold" || sourceType == "trending" || sourceType == "latest" || sourceType == "custom") 65 { 66 var groupsToRelateTo = Model.Item.GetList("RelateTo")?.GetRawValue().OfType<string>().ToList(); 67 68 if (groupsToRelateTo != null) { 69 foreach (var fromGroup in groupsToRelateTo) 70 { 71 var groupId = fromGroup.Length > 2 ? fromGroup.Remove(0, 2) : fromGroup; 72 73 if (!fromGroup.Contains("p_")) 74 { 75 relateFromGroupIds.Add(groupId); 76 } 77 } 78 } 79 80 if (relateToViewModel?.Products != null) 81 { 82 foreach (var fromProduct in relateToViewModel.Products) 83 { 84 var groupId = fromProduct.PrimaryOrDefaultGroup.Id; 85 relateFromGroupIds.Add(groupId); 86 } 87 } 88 } 89 90 string relationGroupId = Model.Item.GetRawValueString("RelationGroup", string.Empty); 91 92 //--- RELATED GROUP --- 93 if (sourceType == "related") 94 { 95 if (relateToViewModel?.Products != null) 96 { 97 product = relateToViewModel.Products.FirstOrDefault(); 98 } 99 100 if (product?.RelatedGroups != null) 101 { 102 foreach (var relationGroup in product.RelatedGroups) 103 { 104 if (relationGroup.Id == relationGroupId) { 105 hasVariants = relationGroup.Products.Any(p => !string.IsNullOrEmpty(p.VariantId)); 106 foreach (var fromProduct in relationGroup.Products) 107 { 108 if (hasVariants) 109 { 110 if (!string.IsNullOrEmpty(fromProduct.VariantId)) 111 { 112 relateFromProductVariantIds.Add($"{fromProduct.ProductId} {fromProduct.VariantId}"); 113 } 114 else 115 { 116 relateFromProductVariantIds.Add($"{fromProduct.ProductId}"); 117 } 118 } 119 relateFromProductIds.Add($"{fromProduct.ProductId}"); 120 } 121 } 122 } 123 } 124 } 125 126 127 //Create group id collection and products id collection strings 128 string productIds = relateFromProductIds.Count > 0 ? string.Join(",", relateFromProductIds) : ""; 129 string productVariantIds = relateFromProductVariantIds.Count > 0 ? string.Join(",", relateFromProductVariantIds) : ""; 130 string groupIds = relateFromGroupIds.Count > 0 ? string.Join(",", relateFromGroupIds) : ""; 131 132 if (product is object) 133 { 134 if (string.IsNullOrEmpty(productIds) && (sourceType == "variants" || sourceType == "frequently" || sourceType == "selected" || sourceType == "custom")) 135 { 136 productIds = product.Id; 137 } 138 139 if (string.IsNullOrEmpty(groupIds) && (sourceType == "most-sold" || sourceType == "trending" || sourceType == "latest")) 140 { 141 groupIds = product.PrimaryOrDefaultGroup.Id; 142 } 143 } 144 } 145 146 @*Container element for the request*@ 147 @if (!string.IsNullOrEmpty(productIds) || !string.IsNullOrEmpty(groupIds) || (string.IsNullOrEmpty(productIds) && string.IsNullOrEmpty(groupIds) && sourceType != "related")) 148 { 149 <form method="post" action="@url" id="ComponentSliderProductsForm_@Model.ID" data-response-target-element="ComponentSliderProducts_@Model.ID" data-preloader="inline" data-update-url="false" class="item_@Model.Item.SystemName.ToLower()"> 150 <input type="hidden" name="ParagraphId" value="@Model.ID" /> 151 <input type="hidden" name="SortOrder" value="DESC"> 152 <input type="hidden" name="SourceType" value="@sourceType"> 153 154 @if (!string.IsNullOrEmpty(groupIds)) 155 { 156 <input type="hidden" name="GroupId" value="@groupIds"> 157 } 158 @if (sourceType != "frequently" && sourceType != "variants" && !string.IsNullOrEmpty(productIds) && !hasVariants) 159 { 160 <input type="hidden" name="MainProductId" value="@productIds"> 161 } 162 @if (sourceType != "frequently" && hasVariants) 163 { 164 <input type="hidden" name="ProductVariantId" value="@productVariantIds"> 165 } 166 167 @if (Model.Item.GetInt32("ProductsCount") != 0) 168 { 169 <input type="hidden" name="PageSize" value="@Model.Item.GetInt32("ProductsCount")"> 170 } 171 172 @if (sourceType == "variants") 173 { 174 <input type="hidden" name="MasterProductID" value="@productIds"> 175 <input type="hidden" name="isVariant" value="true"> 176 } 177 @if (sourceType == "most-sold") 178 { 179 <input type="hidden" name="SortBy" value="OrderCount"> 180 } 181 @if (sourceType == "trending") 182 { 183 <input type="hidden" name="SortBy" value="OrderCountGrowth"> 184 } 185 @if (sourceType == "frequently" && !string.IsNullOrEmpty(productIds)) 186 { 187 <input type="hidden" name="BoughtWithProductIds" value="[@productIds]"> 188 } 189 @if (sourceType == "latest") 190 { 191 <input type="hidden" name="SortBy" value="Created"> 192 } 193 </form> 194 195 <div class="w-100 h-100" data-dw-colorscheme="@Model.ColorScheme?.Id"> 196 <div id="ComponentSliderProducts_@Model.ID" class="h-100" style="@lazyHeight"></div> 197 </div> 198 199 <script type="module"> 200 const productSliderContainer = document.querySelector("#ComponentSliderProducts_@Model.ID"); 201 const productSliderForm = document.querySelector("#ComponentSliderProductsForm_@Model.ID"); 202 203 swift.PageUpdater.Update(productSliderForm); 204 productSliderForm.addEventListener("updated.swift.pageupdater", function(e){ 205 if (e.detail.html === "") { 206 productSliderContainer.closest("[data-col-size]").classList.add("d-none"); 207 } 208 }); 209 </script> 210 } 211 else if (Pageview.IsVisualEditorMode == true) 212 { 213 <div class="alert alert-dark" role="alert"> 214 <span>@Translate("Product component slider: The slider will be rendered here, if there is anything to show")</span> 215 </div> 216 } 217