Monteringssats Enkelfack

120461
554,00 kr InStock
692,50 kr Incl. VAT
Error executing template "Designs/Swift/Paragraph/Swift_ProductStockLocations.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_7a0d163c810b417d81fb577f966f5d3e.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)
   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 @{ 5 ProductViewModel product = null; 6 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 7 { 8 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 9 } 10 else if (Pageview.Page.Item["DummyProduct"] != null && Pageview.IsVisualEditorMode) 11 { 12 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 13 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 14 15 if (productList?.Products is object) 16 { 17 product = productList.Products[0]; 18 } 19 } 20 } 21 22 @if (product is object && product.ProductType == Dynamicweb.Ecommerce.Products.ProductType.Stock) 23 { 24 string horizontalAlign = Model.Item.GetRawValueString("HorizontalAlignment", ""); 25 horizontalAlign = horizontalAlign == "center" ? "justify-content-center" : horizontalAlign; 26 horizontalAlign = horizontalAlign == "end" ? "justify-content-end" : horizontalAlign; 27 28 string modalId = $"stockLocationModal_{Model.ID}_{product.Id}"; 29 modalId += !string.IsNullOrEmpty(product.VariantId) ? $"_{product.VariantId}" : ""; 30 31 var StockService = new Dynamicweb.Ecommerce.Stocks.StockService(); 32 33 bool isProductList = Model.Item.GetBoolean("IsProductList"); 34 var cultureName = Pageview.Area.CultureInfo.Name; 35 string currentStockLocation = ""; 36 if (cultureName.Contains("-")) 37 { 38 currentStockLocation = cultureName.Split('-')[1]; 39 } 40 else 41 { 42 currentStockLocation = cultureName; 43 } 44 45 // Capo custom 46 var user = Dynamicweb.Security.UserManagement.User.GetCurrentUser(); 47 int trustedPartnerGroupdId = 30932; // NOTE: Should this be hardcoded? 48 int bcInternalGroupId = 1211; // NOTE: Should this be hardcoded? 49 bool show = false; 50 foreach (var userGroup in user.Groups) 51 { 52 if (userGroup.ID == trustedPartnerGroupdId || userGroup.ParentID == bcInternalGroupId) 53 { 54 show = true; 55 } 56 } 57 58 if (StockService.GetStockUnits(product.Id, product.VariantId).Any()) 59 { 60 <div class="item_@Model.Item.SystemName.ToLower() @(show ? "" : "d-none")"> 61 @if (!isProductList) 62 { 63 <h3 class="h6">@Translate("Stockstatus")</h3> 64 65 <table border="1" cellpadding="5" cellspacing="0" style="width: 100%; border: 0"> 66 @foreach (var unit in StockService.GetStockUnits(product.Id, product.VariantId).OrderBy(s => StockService.GetStockLocation(s.StockLocationId).GetDescription(Pageview.Area.EcomLanguageId))) 67 { 68 bool inStock = unit.StockQuantity > 0; 69 70 // Capo custom 71 var StockLocation = StockService.GetStockLocation(unit.StockLocationId); 72 string stockLocationName = StockLocation.GetName(Pageview.Area.EcomLanguageId); 73 74 string stockLocationMarketSuffix = stockLocationName.Substring(stockLocationName.LastIndexOf("_") + 1, 2); 75 string marketInventoryType = ""; 76 77 if (product.ProductFields.TryGetValue("InventoryType_" + stockLocationMarketSuffix, out FieldValueViewModel? marketInventoryTypeObject) 78 && !string.IsNullOrEmpty(Dynamicweb.Core.Converter.ToString(marketInventoryTypeObject.Value))) 79 { 80 marketInventoryType = Dynamicweb.Core.Converter.ToString(marketInventoryTypeObject.Value); 81 } 82 83 <tr style="@(currentStockLocation.ToLower() == stockLocationMarketSuffix.ToLower() ? "font-weight: bold;" : "")"> 84 <td>@stockLocationName</td> 85 <td>@marketInventoryType</td> 86 @if (unit.StockQuantity > 0) 87 { 88 <td style="text-align: right;" class="text-success">@Translate("In stock"): @unit.StockQuantity</td> 89 } 90 else 91 { 92 <td style="text-align: right;" class="text-danger">@Translate("Out of stock")</td> 93 } 94 </tr> 95 } 96 </table> 97 } 98 else 99 { 100 foreach (var unit in StockService.GetStockUnits(product.Id, product.VariantId).OrderBy(s => StockService.GetStockLocation(s.StockLocationId).GetDescription(Pageview.Area.EcomLanguageId))) 101 { 102 bool inStock = unit.StockQuantity > 0; 103 // Capo custom 104 var StockLocation = StockService.GetStockLocation(unit.StockLocationId); 105 string stockLocationName = StockLocation.GetName(Pageview.Area.EcomLanguageId); 106 107 string stockLocationMarketSuffix = stockLocationName.Substring(stockLocationName.LastIndexOf("_") + 1, 2); 108 109 if (currentStockLocation.ToLower() == stockLocationMarketSuffix.ToLower()) 110 { 111 if (unit.StockQuantity > 0) 112 { 113 <span class="text-success">@Translate("In stock"): @unit.StockQuantity</span> 114 } 115 else 116 { 117 <span class="text-danger">@Translate("Out of stock")</span> 118 } 119 } 120 121 } 122 } 123 </div> 124 } 125 126 } 127 else if (Pageview.IsVisualEditorMode) 128 { 129 <div class="alert alert-info">@Translate("No products available")</div> 130 } 131

Shipping

Delivery within 7 work days

Warranty

3 years warranty

Specifications

Number 120461

Liknande produkter

By clicking 'Accept All' you consent that we may collect information about you for various purposes, including: Statistics and Marketing