Reservedele og tilbehør efter mærker

Vi har et stort udvalg af reservedele til populære mærker som Bosch, Siemens, AEG, Miele, Electrolux og mange flere. Vores udvalg omfatter alt fra ovn- og køleskabsdele til reservedele til støvsugere og kaffemaskiner. Alle vores reservedele er af høj kvalitet og passer perfekt til det originale produkt. Med Reservedele.nu har du nem adgang til reservedele til dine yndlingshvidevarer og småapparater, så du kan holde dem i god form og forlænge deres levetid. Vælg dit mærke i listen herunder.

 

Error executing template "Designs/Swift/Paragraph/Swift_ProductListItemRepeater.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_5dbfd6c2518e46658dcc6372c664cbdd.<RenderProductList>b__1_0(TextWriter __razor_helper_writer) in D:\dynamicweb.net\Solutions\smartpage\vmelektro.cloud.dynamicweb-cms.com\Files\Templates\Designs\Swift\Paragraph\Swift_ProductListItemRepeater.cshtml:line 292
   at CompiledRazorTemplates.Dynamic.RazorEngine_5dbfd6c2518e46658dcc6372c664cbdd.Execute() in D:\dynamicweb.net\Solutions\smartpage\vmelektro.cloud.dynamicweb-cms.com\Files\Templates\Designs\Swift\Paragraph\Swift_ProductListItemRepeater.cshtml:line 40
   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.Core 4 @using Dynamicweb.Ecommerce.CustomerExperienceCenter.Favorites 5 @using Dynamicweb.Environment 6 7 @functions 8 { 9 string liveInfoClass = ""; 10 } 11 12 @{ 13 bool isDetailPage = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("ProductID")); 14 string theme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Theme")) ? " theme " + Model.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : ""; 15 16 string productInfoFeed = ""; 17 bool isLazyLoadingForProductInfoEnabled = Dynamicweb.Ecommerce.DynamicwebLiveIntegration.TemplatesHelper.IsLazyLoadingForProductInfoEnabled; 18 if (isLazyLoadingForProductInfoEnabled) 19 { 20 if (Dynamicweb.Context.Current.Items.Contains("ProductInfoFeed")) 21 { 22 productInfoFeed = Dynamicweb.Context.Current.Items["ProductInfoFeed"]?.ToString(); 23 if (!string.IsNullOrEmpty(productInfoFeed)) 24 { 25 productInfoFeed = $"data-product-info-feed=\"{productInfoFeed}\""; 26 } 27 } 28 liveInfoClass = "js-live-info"; 29 } 30 31 } 32 33 @if (!isDetailPage) { 34 if (!string.IsNullOrEmpty(theme)) { 35 <div class="h-100@(theme) item_@Model.Item.SystemName.ToLower()" @productInfoFeed> 36 @RenderProductList() 37 </div> 38 } else { 39 <div class="item_@Model.Item.SystemName.ToLower()" @productInfoFeed> 40 @RenderProductList() 41 </div> 42 } 43 } 44 45 @helper RenderProductList () { 46 bool isVisualEditor = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("VisualEdit")) ? Convert.ToBoolean(Dynamicweb.Context.Current.Request.QueryString.Get("VisualEdit")) : false; 47 48 ProductListViewModel productList = new ProductListViewModel(); 49 50 string googleAnalyticsTrackingID = Pageview.AreaSettings.GetString("GoogleAnalyticsTrackingID"); 51 string googleAnalyticsMeasurementID = Pageview.AreaSettings.GetString("GoogleAnalyticsMeasurementID"); 52 var cookieOptInLevel = CookieManager.GetCookieOptInLevel(); 53 bool allowTracking = cookieOptInLevel == CookieOptInLevel.All || (cookieOptInLevel == CookieOptInLevel.Functional && CookieManager.GetCookieOptInCategories().Contains("Statistical")); 54 55 ProductListViewModelSettings productListSetting = new ProductListViewModelSettings 56 { 57 LanguageId = Dynamicweb.Ecommerce.Common.Context.LanguageID, 58 CurrencyCode = Dynamicweb.Ecommerce.Common.Context.Currency.Code, 59 CountryCode = Dynamicweb.Ecommerce.Common.Context.Country.Code2, 60 ShopId = Pageview.Area.EcomShopId 61 }; 62 63 int productsCount = 0; 64 int maxProductsCounter = 0; 65 66 if (Dynamicweb.Context.Current.Items.Contains("ProductList")) 67 { 68 productList = (ProductListViewModel)Dynamicweb.Context.Current.Items["ProductList"]; 69 } 70 else if (Pageview.Item["DummyProductGroup"] != null) 71 { 72 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 73 ProductListViewModel groupList = pageViewModel.Item.GetValue("DummyProductGroup") != null ? pageViewModel.Item.GetValue("DummyProductGroup") as ProductListViewModel : new ProductListViewModel(); 74 75 if (groupList?.Group?.Id != null) { 76 productList = ViewModelFactory.CreateView(productListSetting, groupList.Group.Id); 77 Dynamicweb.Context.Current.Items.Add("ProductList", productList); 78 } else { 79 productList = ViewModelFactory.CreateView(productListSetting, Dynamicweb.Ecommerce.Services.ProductGroups.GetGroups(Dynamicweb.Ecommerce.Common.Context.LanguageID).FirstOrDefault().Id); 80 81 Dynamicweb.Context.Current.Items.Add("ProductList", productList); 82 } 83 } 84 else if (Pageview.Item["DummyProductGroup"] == null) { 85 productList = ViewModelFactory.CreateView(productListSetting, Dynamicweb.Ecommerce.Services.ProductGroups.GetGroups(Dynamicweb.Ecommerce.Common.Context.LanguageID).FirstOrDefault().Id); 86 Dynamicweb.Context.Current.Items.Add("ProductList", productList); 87 } 88 89 if (Pageview.Page.Item.SystemName == "Swift_ProductListComponentEdit") { 90 if (productList.TotalProductsCount == 0) { 91 ProductViewModelSettings productSetting = new ProductViewModelSettings 92 { 93 LanguageId = Dynamicweb.Ecommerce.Common.Context.LanguageID, 94 CurrencyCode = Dynamicweb.Ecommerce.Common.Context.Currency.Code, 95 CountryCode = Dynamicweb.Ecommerce.Common.Context.Country.Code2, 96 ShopId = Pageview.Area.EcomShopId 97 }; 98 99 foreach (var product in Dynamicweb.Ecommerce.Services.Products.GetLastActiveProducts(3, Dynamicweb.Ecommerce.Common.Context.LanguageID, false)) { 100 var productView = ViewModelFactory.CreateView(productSetting, product.Id); 101 productList.Products.Add(productView); 102 } 103 104 Dynamicweb.Context.Current.Items["ProductList"] = productList; 105 } 106 107 productList.TotalProductsCount = 3; 108 productList.PageSize = 3; 109 maxProductsCounter = 3; 110 } 111 112 string groupId = productList?.Group?.Id != null ? productList.Group.Id : ""; 113 string url = Dynamicweb.Context.Current.Request.RawUrl; 114 115 if (productList.TotalProductsCount > 0) { 116 int pageSizeSetting = 12; 117 //var productCatalogSettings = new ProductCatalogSettings(Pageview.CurrentParagraph.ModuleProperties); 118 //int pageSizeSetting = productCatalogSettings.PageSize; 119 120 int pageSize = productList.PageSize; 121 pageSize += pageSizeSetting; 122 123 int loadedProducts = productList.PageSize > productList.TotalProductsCount ? productList.TotalProductsCount : productList.PageSize; 124 string searchQuery = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("q")) ? Dynamicweb.Context.Current.Request.QueryString.Get("q") : ""; 125 126 int listItemSourcePageId = Model.Item.GetInt32("ListComponentSource"); 127 var page = Dynamicweb.Services.Pages.GetPage(listItemSourcePageId); 128 129 if (page != null) { 130 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(page); 131 132 string gridColumnSize = Model.Item.GetRawValueString("GridLayoutDesktop", "3-columns"); 133 gridColumnSize = gridColumnSize == "2-columns" ? "g-col-lg-6" : gridColumnSize; 134 gridColumnSize = gridColumnSize == "3-columns" ? "g-col-lg-4" : gridColumnSize; 135 gridColumnSize = gridColumnSize == "4-columns" ? "g-col-lg-3" : gridColumnSize; 136 gridColumnSize = gridColumnSize == "6-columns" ? "g-col-lg-2" : gridColumnSize; 137 gridColumnSize = gridColumnSize == "list" ? "" : gridColumnSize; 138 139 string gridColumnMobileSize = Model.Item.GetRawValueString("GridLayoutMobile", "2-columns"); 140 gridColumnMobileSize = gridColumnMobileSize == "list" ? "g-col-12" : gridColumnMobileSize; 141 gridColumnMobileSize = gridColumnMobileSize == "2-columns" ? "g-col-6" : gridColumnMobileSize; 142 143 string listItemTheme = " theme " + pageViewModel.Item.GetRawValueString("Theme", string.Empty).Replace(" ", "").Trim().ToLower(); 144 string listItemPadding = pageViewModel.Item.GetRawValueString("ContentPadding", string.Empty); 145 string listItemPaddingClass = string.Empty; 146 147 switch(listItemPadding) 148 { 149 case "small": 150 listItemPaddingClass = " p-2 p-xl-3"; 151 break; 152 case "large": 153 listItemPaddingClass = " p-3 p-xl-4"; 154 break; 155 case "small-x": 156 listItemPaddingClass = " px-2 px-md-3"; 157 break; 158 case "large-x": 159 listItemPaddingClass = " px-3 px-md-4"; 160 break; 161 } 162 163 <div class="grid"> 164 @if (!string.IsNullOrWhiteSpace(googleAnalyticsMeasurementID) && allowTracking) 165 { 166 <script> 167 gtag("event", "view_item_list", { 168 item_list_id: "product_list_item_repeater", 169 item_list_name: "Product list (Item Repeater)", 170 items: [ 171 @foreach (ProductViewModel product in productList.Products) 172 { 173 <text>{ 174 item_id: "@product.Number", 175 item_name: "@product.Name", 176 currency: "@product.Price.CurrencyCode", 177 price: @product.Price.Price 178 },</text> 179 } 180 ] 181 }); 182 </script> 183 } 184 185 @foreach (ProductViewModel product in productList.Products) 186 { 187 if (maxProductsCounter == 0 || (productsCount < maxProductsCounter)) { 188 string detailsPageLink = !string.IsNullOrEmpty(GetPageIdByNavigationTag("Shop").ToString()) ? GetPageIdByNavigationTag("Shop").ToString() : string.Empty; 189 string selectedDetailPage = Dynamicweb.Ecommerce.Services.ProductGroups.GetGroup(product.PrimaryOrDefaultGroup.Id)?.Meta.PrimaryPage ?? string.Empty; 190 string detailsPageId = detailsPageLink != string.Empty ? detailsPageLink.Substring(detailsPageLink.LastIndexOf('=') + 1) : string.Empty; 191 string selectedDetailPageId = selectedDetailPage != string.Empty ? selectedDetailPage.Substring(selectedDetailPage.LastIndexOf('=') + 1) : string.Empty; 192 detailsPageId = string.IsNullOrEmpty(selectedDetailPage) ? detailsPageId : selectedDetailPageId; 193 194 string variantIdForLink = !string.IsNullOrEmpty(product.VariantId) ? $"&VariantID={product.VariantId}" : ""; 195 variantIdForLink = string.IsNullOrEmpty(variantIdForLink) && !string.IsNullOrEmpty(product.DefaultVariantId) ? $"&VariantID={product.DefaultVariantId}" : variantIdForLink; 196 197 string link = "Default.aspx?ID=" + GetPageIdByNavigationTag("Shop"); 198 link += $"&GroupID={product.PrimaryOrDefaultGroup.Id}"; 199 link += $"&ProductID={product.Id}"; 200 link += variantIdForLink; 201 link = Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(link); 202 203 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 204 { 205 Dynamicweb.Context.Current.Items["ProductDetails"] = product; 206 } 207 else 208 { 209 Dynamicweb.Context.Current.Items.Add("ProductDetails", product); 210 } 211 212 if (Model.Item.GetString("ListComponentSource") != null) { 213 <article class="@gridColumnMobileSize @gridColumnSize @listItemTheme @listItemPaddingClass d-flex flex-column position-relative product js-product @liveInfoClass" data-product-id="@product.Id" itemscope itemtype="https://schema.org/Product"> 214 @{ 215 string clickProductLink = string.Empty; 216 if (!string.IsNullOrWhiteSpace(googleAnalyticsMeasurementID) && allowTracking) 217 { 218 clickProductLink = "onclick=\"return clickProductLink('" + @product.Id + "', '" + @product.Name + "', '" + @product.VariantName + "', '" + @product.Price.CurrencyCode + "', '" + @product.Price.Price + "')\""; 219 } 220 } 221 <a href="@link" class="stretched-link" @clickProductLink> 222 <span class="visually-hidden">@product.Name</span> 223 </a> 224 @if (!string.IsNullOrWhiteSpace(googleAnalyticsMeasurementID) && allowTracking) 225 { 226 <script> 227 function clickProductLink(productId, productName, productVariant, productCurrency, productPrice) { 228 if (typeof gtag !== "undefined") { 229 gtag("event", "select_item", { 230 item_list_id: "product_list_item_repeater", 231 item_list_name: "Product list (Item Repeater)", 232 items: [ 233 { 234 item_id: productId, 235 item_name: productName, 236 currency: productCurrency, 237 item_list_id: "product_list_item_repeater", 238 item_list_name: "Product list (Item Repeater)", 239 item_variant: productVariant, 240 price: productPrice 241 } 242 ] 243 }); 244 } 245 } 246 </script> 247 } 248 @RenderGrid(listItemSourcePageId) 249 </article> 250 } 251 252 productsCount++; 253 } 254 } 255 </div> 256 257 <div class="my-3"> 258 <div class="text-center"> 259 <div class="opacity-85 mb-3">@loadedProducts @Translate("out of") @productList.TotalProductsCount @Translate("products")</div> 260 @if (productList.PageCount != 1 && maxProductsCounter == 0) { 261 string sortBySelection = Dynamicweb.Context.Current.Request?.Form["SortBy"] ?? "Relevance"; 262 sortBySelection = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("SortBy")) ? Dynamicweb.Context.Current.Request.QueryString.Get("SortBy") : sortBySelection; 263 264 <form method="get" action="@url" data-response-target-element="content" class="w-100"> 265 @if (productList?.FacetGroups != null) { 266 foreach (FacetGroupViewModel facetGroup in productList.FacetGroups) 267 { 268 foreach (FacetViewModel facetItem in facetGroup.Facets) 269 { 270 foreach (FacetOptionViewModel facetOption in facetItem.Options) 271 { 272 if (facetOption.Selected) 273 { 274 <input type="hidden" name="@facetItem.QueryParameter" value="[@facetOption.Value]"> 275 } 276 } 277 } 278 } 279 } 280 281 @if (productList?.Group?.Id != null) { 282 <input type="hidden" name="GroupId" value="@productList.Group.Id"> 283 } 284 285 <input type="hidden" name="PageSize" value="@pageSize"> 286 <input type="hidden" name="SortBy" value="@sortBySelection"> 287 <input type="hidden" name="RequestType" value="UpdateList"> 288 289 @{ 290 string nextPageLink = "/Default.aspx?ID=" + Pageview.Page.ID + "&PageSize=" + pageSize + "&SortBy=" + sortBySelection; 291 292 foreach (FacetGroupViewModel facetGroup in productList.FacetGroups) 293 { 294 foreach (FacetViewModel facetItem in facetGroup.Facets) 295 { 296 foreach (FacetOptionViewModel facetOption in facetItem.Options) 297 { 298 if (facetOption.Selected) 299 { 300 nextPageLink += "&" + facetItem.QueryParameter + "=[" + facetOption.Value + "]"; 301 } 302 } 303 } 304 } 305 306 nextPageLink += productList?.Group?.Id != null ? "&GroupID=" + productList.Group.Id : ""; 307 nextPageLink += !string.IsNullOrEmpty(searchQuery) ? "&q=" + searchQuery : ""; 308 } 309 310 <a href="@nextPageLink" class="btn btn-primary" type="button" onclick="swift.ProductList.Update(event)" id="LoadMoreButton_@Model.ID">@Translate("Load more products")</a> 311 </form> 312 } 313 </div> 314 </div> 315 316 <script> 317 function switchVariantProduct(id, price, imagesrc) { 318 var productImageElement = document.querySelector("#ProductImage_" + id); 319 var productPriceElement = document.querySelector("#ProductPrice_" + id + " .text-price"); 320 321 if (productPriceElement) { 322 productPriceElement.innerText = price; 323 } 324 325 if (productImageElement) { 326 productImageElement.src = imagesrc; 327 328 var imageSrcset = productImageElement.srcset; 329 imageSrcset = imageSrcset.replace(/image=.*?&/g, 'image=' + imagesrc + "&"); 330 331 productImageElement.srcset = imageSrcset; 332 } 333 } 334 </script> 335 } else if (Pageview.IsVisualEditorMode) { 336 <div class="alert alert-dark m-0" role="alert"> 337 <span>@Translate("The selected component does not exist anymore")</span> 338 </div> 339 } 340 } else { 341 string noProductsFoundMessage = !string.IsNullOrEmpty(Model.Item.GetString("NoProductsFoundMessage")) ? Model.Item.GetString("NoProductsFoundMessage") : Translate("We did not find anything matching your search result"); 342 bool hasSubgroups = false; 343 344 if (productList.SubGroups != null) 345 { 346 hasSubgroups = productList.SubGroups.Any(); 347 } 348 349 if (!Model.Item.GetBoolean("HideNoProductsFoundMessage")) { 350 if (!isVisualEditor) 351 { 352 <div class="alert alert-dark m-0" role="alert"> 353 @noProductsFoundMessage 354 </div> 355 } else { 356 <div class="alert alert-dark m-0" role="alert"> 357 @Translate("Product list: The list will be shown here, if any") 358 </div> 359 } 360 } else if (!hasSubgroups) 361 { 362 <div class="alert alert-dark m-0" role="alert"> 363 @noProductsFoundMessage 364 </div> 365 } 366 } 367 } 368

Sortering

Error executing template "Designs/Swift/Paragraph/Swift_ProductListItemRepeater.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_5dbfd6c2518e46658dcc6372c664cbdd.<RenderProductList>b__1_0(TextWriter __razor_helper_writer) in D:\dynamicweb.net\Solutions\smartpage\vmelektro.cloud.dynamicweb-cms.com\Files\Templates\Designs\Swift\Paragraph\Swift_ProductListItemRepeater.cshtml:line 292
   at CompiledRazorTemplates.Dynamic.RazorEngine_5dbfd6c2518e46658dcc6372c664cbdd.Execute() in D:\dynamicweb.net\Solutions\smartpage\vmelektro.cloud.dynamicweb-cms.com\Files\Templates\Designs\Swift\Paragraph\Swift_ProductListItemRepeater.cshtml:line 40
   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.Core 4 @using Dynamicweb.Ecommerce.CustomerExperienceCenter.Favorites 5 @using Dynamicweb.Environment 6 7 @functions 8 { 9 string liveInfoClass = ""; 10 } 11 12 @{ 13 bool isDetailPage = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("ProductID")); 14 string theme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Theme")) ? " theme " + Model.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : ""; 15 16 string productInfoFeed = ""; 17 bool isLazyLoadingForProductInfoEnabled = Dynamicweb.Ecommerce.DynamicwebLiveIntegration.TemplatesHelper.IsLazyLoadingForProductInfoEnabled; 18 if (isLazyLoadingForProductInfoEnabled) 19 { 20 if (Dynamicweb.Context.Current.Items.Contains("ProductInfoFeed")) 21 { 22 productInfoFeed = Dynamicweb.Context.Current.Items["ProductInfoFeed"]?.ToString(); 23 if (!string.IsNullOrEmpty(productInfoFeed)) 24 { 25 productInfoFeed = $"data-product-info-feed=\"{productInfoFeed}\""; 26 } 27 } 28 liveInfoClass = "js-live-info"; 29 } 30 31 } 32 33 @if (!isDetailPage) { 34 if (!string.IsNullOrEmpty(theme)) { 35 <div class="h-100@(theme) item_@Model.Item.SystemName.ToLower()" @productInfoFeed> 36 @RenderProductList() 37 </div> 38 } else { 39 <div class="item_@Model.Item.SystemName.ToLower()" @productInfoFeed> 40 @RenderProductList() 41 </div> 42 } 43 } 44 45 @helper RenderProductList () { 46 bool isVisualEditor = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("VisualEdit")) ? Convert.ToBoolean(Dynamicweb.Context.Current.Request.QueryString.Get("VisualEdit")) : false; 47 48 ProductListViewModel productList = new ProductListViewModel(); 49 50 string googleAnalyticsTrackingID = Pageview.AreaSettings.GetString("GoogleAnalyticsTrackingID"); 51 string googleAnalyticsMeasurementID = Pageview.AreaSettings.GetString("GoogleAnalyticsMeasurementID"); 52 var cookieOptInLevel = CookieManager.GetCookieOptInLevel(); 53 bool allowTracking = cookieOptInLevel == CookieOptInLevel.All || (cookieOptInLevel == CookieOptInLevel.Functional && CookieManager.GetCookieOptInCategories().Contains("Statistical")); 54 55 ProductListViewModelSettings productListSetting = new ProductListViewModelSettings 56 { 57 LanguageId = Dynamicweb.Ecommerce.Common.Context.LanguageID, 58 CurrencyCode = Dynamicweb.Ecommerce.Common.Context.Currency.Code, 59 CountryCode = Dynamicweb.Ecommerce.Common.Context.Country.Code2, 60 ShopId = Pageview.Area.EcomShopId 61 }; 62 63 int productsCount = 0; 64 int maxProductsCounter = 0; 65 66 if (Dynamicweb.Context.Current.Items.Contains("ProductList")) 67 { 68 productList = (ProductListViewModel)Dynamicweb.Context.Current.Items["ProductList"]; 69 } 70 else if (Pageview.Item["DummyProductGroup"] != null) 71 { 72 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 73 ProductListViewModel groupList = pageViewModel.Item.GetValue("DummyProductGroup") != null ? pageViewModel.Item.GetValue("DummyProductGroup") as ProductListViewModel : new ProductListViewModel(); 74 75 if (groupList?.Group?.Id != null) { 76 productList = ViewModelFactory.CreateView(productListSetting, groupList.Group.Id); 77 Dynamicweb.Context.Current.Items.Add("ProductList", productList); 78 } else { 79 productList = ViewModelFactory.CreateView(productListSetting, Dynamicweb.Ecommerce.Services.ProductGroups.GetGroups(Dynamicweb.Ecommerce.Common.Context.LanguageID).FirstOrDefault().Id); 80 81 Dynamicweb.Context.Current.Items.Add("ProductList", productList); 82 } 83 } 84 else if (Pageview.Item["DummyProductGroup"] == null) { 85 productList = ViewModelFactory.CreateView(productListSetting, Dynamicweb.Ecommerce.Services.ProductGroups.GetGroups(Dynamicweb.Ecommerce.Common.Context.LanguageID).FirstOrDefault().Id); 86 Dynamicweb.Context.Current.Items.Add("ProductList", productList); 87 } 88 89 if (Pageview.Page.Item.SystemName == "Swift_ProductListComponentEdit") { 90 if (productList.TotalProductsCount == 0) { 91 ProductViewModelSettings productSetting = new ProductViewModelSettings 92 { 93 LanguageId = Dynamicweb.Ecommerce.Common.Context.LanguageID, 94 CurrencyCode = Dynamicweb.Ecommerce.Common.Context.Currency.Code, 95 CountryCode = Dynamicweb.Ecommerce.Common.Context.Country.Code2, 96 ShopId = Pageview.Area.EcomShopId 97 }; 98 99 foreach (var product in Dynamicweb.Ecommerce.Services.Products.GetLastActiveProducts(3, Dynamicweb.Ecommerce.Common.Context.LanguageID, false)) { 100 var productView = ViewModelFactory.CreateView(productSetting, product.Id); 101 productList.Products.Add(productView); 102 } 103 104 Dynamicweb.Context.Current.Items["ProductList"] = productList; 105 } 106 107 productList.TotalProductsCount = 3; 108 productList.PageSize = 3; 109 maxProductsCounter = 3; 110 } 111 112 string groupId = productList?.Group?.Id != null ? productList.Group.Id : ""; 113 string url = Dynamicweb.Context.Current.Request.RawUrl; 114 115 if (productList.TotalProductsCount > 0) { 116 int pageSizeSetting = 12; 117 //var productCatalogSettings = new ProductCatalogSettings(Pageview.CurrentParagraph.ModuleProperties); 118 //int pageSizeSetting = productCatalogSettings.PageSize; 119 120 int pageSize = productList.PageSize; 121 pageSize += pageSizeSetting; 122 123 int loadedProducts = productList.PageSize > productList.TotalProductsCount ? productList.TotalProductsCount : productList.PageSize; 124 string searchQuery = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("q")) ? Dynamicweb.Context.Current.Request.QueryString.Get("q") : ""; 125 126 int listItemSourcePageId = Model.Item.GetInt32("ListComponentSource"); 127 var page = Dynamicweb.Services.Pages.GetPage(listItemSourcePageId); 128 129 if (page != null) { 130 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(page); 131 132 string gridColumnSize = Model.Item.GetRawValueString("GridLayoutDesktop", "3-columns"); 133 gridColumnSize = gridColumnSize == "2-columns" ? "g-col-lg-6" : gridColumnSize; 134 gridColumnSize = gridColumnSize == "3-columns" ? "g-col-lg-4" : gridColumnSize; 135 gridColumnSize = gridColumnSize == "4-columns" ? "g-col-lg-3" : gridColumnSize; 136 gridColumnSize = gridColumnSize == "6-columns" ? "g-col-lg-2" : gridColumnSize; 137 gridColumnSize = gridColumnSize == "list" ? "" : gridColumnSize; 138 139 string gridColumnMobileSize = Model.Item.GetRawValueString("GridLayoutMobile", "2-columns"); 140 gridColumnMobileSize = gridColumnMobileSize == "list" ? "g-col-12" : gridColumnMobileSize; 141 gridColumnMobileSize = gridColumnMobileSize == "2-columns" ? "g-col-6" : gridColumnMobileSize; 142 143 string listItemTheme = " theme " + pageViewModel.Item.GetRawValueString("Theme", string.Empty).Replace(" ", "").Trim().ToLower(); 144 string listItemPadding = pageViewModel.Item.GetRawValueString("ContentPadding", string.Empty); 145 string listItemPaddingClass = string.Empty; 146 147 switch(listItemPadding) 148 { 149 case "small": 150 listItemPaddingClass = " p-2 p-xl-3"; 151 break; 152 case "large": 153 listItemPaddingClass = " p-3 p-xl-4"; 154 break; 155 case "small-x": 156 listItemPaddingClass = " px-2 px-md-3"; 157 break; 158 case "large-x": 159 listItemPaddingClass = " px-3 px-md-4"; 160 break; 161 } 162 163 <div class="grid"> 164 @if (!string.IsNullOrWhiteSpace(googleAnalyticsMeasurementID) && allowTracking) 165 { 166 <script> 167 gtag("event", "view_item_list", { 168 item_list_id: "product_list_item_repeater", 169 item_list_name: "Product list (Item Repeater)", 170 items: [ 171 @foreach (ProductViewModel product in productList.Products) 172 { 173 <text>{ 174 item_id: "@product.Number", 175 item_name: "@product.Name", 176 currency: "@product.Price.CurrencyCode", 177 price: @product.Price.Price 178 },</text> 179 } 180 ] 181 }); 182 </script> 183 } 184 185 @foreach (ProductViewModel product in productList.Products) 186 { 187 if (maxProductsCounter == 0 || (productsCount < maxProductsCounter)) { 188 string detailsPageLink = !string.IsNullOrEmpty(GetPageIdByNavigationTag("Shop").ToString()) ? GetPageIdByNavigationTag("Shop").ToString() : string.Empty; 189 string selectedDetailPage = Dynamicweb.Ecommerce.Services.ProductGroups.GetGroup(product.PrimaryOrDefaultGroup.Id)?.Meta.PrimaryPage ?? string.Empty; 190 string detailsPageId = detailsPageLink != string.Empty ? detailsPageLink.Substring(detailsPageLink.LastIndexOf('=') + 1) : string.Empty; 191 string selectedDetailPageId = selectedDetailPage != string.Empty ? selectedDetailPage.Substring(selectedDetailPage.LastIndexOf('=') + 1) : string.Empty; 192 detailsPageId = string.IsNullOrEmpty(selectedDetailPage) ? detailsPageId : selectedDetailPageId; 193 194 string variantIdForLink = !string.IsNullOrEmpty(product.VariantId) ? $"&VariantID={product.VariantId}" : ""; 195 variantIdForLink = string.IsNullOrEmpty(variantIdForLink) && !string.IsNullOrEmpty(product.DefaultVariantId) ? $"&VariantID={product.DefaultVariantId}" : variantIdForLink; 196 197 string link = "Default.aspx?ID=" + GetPageIdByNavigationTag("Shop"); 198 link += $"&GroupID={product.PrimaryOrDefaultGroup.Id}"; 199 link += $"&ProductID={product.Id}"; 200 link += variantIdForLink; 201 link = Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(link); 202 203 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 204 { 205 Dynamicweb.Context.Current.Items["ProductDetails"] = product; 206 } 207 else 208 { 209 Dynamicweb.Context.Current.Items.Add("ProductDetails", product); 210 } 211 212 if (Model.Item.GetString("ListComponentSource") != null) { 213 <article class="@gridColumnMobileSize @gridColumnSize @listItemTheme @listItemPaddingClass d-flex flex-column position-relative product js-product @liveInfoClass" data-product-id="@product.Id" itemscope itemtype="https://schema.org/Product"> 214 @{ 215 string clickProductLink = string.Empty; 216 if (!string.IsNullOrWhiteSpace(googleAnalyticsMeasurementID) && allowTracking) 217 { 218 clickProductLink = "onclick=\"return clickProductLink('" + @product.Id + "', '" + @product.Name + "', '" + @product.VariantName + "', '" + @product.Price.CurrencyCode + "', '" + @product.Price.Price + "')\""; 219 } 220 } 221 <a href="@link" class="stretched-link" @clickProductLink> 222 <span class="visually-hidden">@product.Name</span> 223 </a> 224 @if (!string.IsNullOrWhiteSpace(googleAnalyticsMeasurementID) && allowTracking) 225 { 226 <script> 227 function clickProductLink(productId, productName, productVariant, productCurrency, productPrice) { 228 if (typeof gtag !== "undefined") { 229 gtag("event", "select_item", { 230 item_list_id: "product_list_item_repeater", 231 item_list_name: "Product list (Item Repeater)", 232 items: [ 233 { 234 item_id: productId, 235 item_name: productName, 236 currency: productCurrency, 237 item_list_id: "product_list_item_repeater", 238 item_list_name: "Product list (Item Repeater)", 239 item_variant: productVariant, 240 price: productPrice 241 } 242 ] 243 }); 244 } 245 } 246 </script> 247 } 248 @RenderGrid(listItemSourcePageId) 249 </article> 250 } 251 252 productsCount++; 253 } 254 } 255 </div> 256 257 <div class="my-3"> 258 <div class="text-center"> 259 <div class="opacity-85 mb-3">@loadedProducts @Translate("out of") @productList.TotalProductsCount @Translate("products")</div> 260 @if (productList.PageCount != 1 && maxProductsCounter == 0) { 261 string sortBySelection = Dynamicweb.Context.Current.Request?.Form["SortBy"] ?? "Relevance"; 262 sortBySelection = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("SortBy")) ? Dynamicweb.Context.Current.Request.QueryString.Get("SortBy") : sortBySelection; 263 264 <form method="get" action="@url" data-response-target-element="content" class="w-100"> 265 @if (productList?.FacetGroups != null) { 266 foreach (FacetGroupViewModel facetGroup in productList.FacetGroups) 267 { 268 foreach (FacetViewModel facetItem in facetGroup.Facets) 269 { 270 foreach (FacetOptionViewModel facetOption in facetItem.Options) 271 { 272 if (facetOption.Selected) 273 { 274 <input type="hidden" name="@facetItem.QueryParameter" value="[@facetOption.Value]"> 275 } 276 } 277 } 278 } 279 } 280 281 @if (productList?.Group?.Id != null) { 282 <input type="hidden" name="GroupId" value="@productList.Group.Id"> 283 } 284 285 <input type="hidden" name="PageSize" value="@pageSize"> 286 <input type="hidden" name="SortBy" value="@sortBySelection"> 287 <input type="hidden" name="RequestType" value="UpdateList"> 288 289 @{ 290 string nextPageLink = "/Default.aspx?ID=" + Pageview.Page.ID + "&PageSize=" + pageSize + "&SortBy=" + sortBySelection; 291 292 foreach (FacetGroupViewModel facetGroup in productList.FacetGroups) 293 { 294 foreach (FacetViewModel facetItem in facetGroup.Facets) 295 { 296 foreach (FacetOptionViewModel facetOption in facetItem.Options) 297 { 298 if (facetOption.Selected) 299 { 300 nextPageLink += "&" + facetItem.QueryParameter + "=[" + facetOption.Value + "]"; 301 } 302 } 303 } 304 } 305 306 nextPageLink += productList?.Group?.Id != null ? "&GroupID=" + productList.Group.Id : ""; 307 nextPageLink += !string.IsNullOrEmpty(searchQuery) ? "&q=" + searchQuery : ""; 308 } 309 310 <a href="@nextPageLink" class="btn btn-primary" type="button" onclick="swift.ProductList.Update(event)" id="LoadMoreButton_@Model.ID">@Translate("Load more products")</a> 311 </form> 312 } 313 </div> 314 </div> 315 316 <script> 317 function switchVariantProduct(id, price, imagesrc) { 318 var productImageElement = document.querySelector("#ProductImage_" + id); 319 var productPriceElement = document.querySelector("#ProductPrice_" + id + " .text-price"); 320 321 if (productPriceElement) { 322 productPriceElement.innerText = price; 323 } 324 325 if (productImageElement) { 326 productImageElement.src = imagesrc; 327 328 var imageSrcset = productImageElement.srcset; 329 imageSrcset = imageSrcset.replace(/image=.*?&/g, 'image=' + imagesrc + "&"); 330 331 productImageElement.srcset = imageSrcset; 332 } 333 } 334 </script> 335 } else if (Pageview.IsVisualEditorMode) { 336 <div class="alert alert-dark m-0" role="alert"> 337 <span>@Translate("The selected component does not exist anymore")</span> 338 </div> 339 } 340 } else { 341 string noProductsFoundMessage = !string.IsNullOrEmpty(Model.Item.GetString("NoProductsFoundMessage")) ? Model.Item.GetString("NoProductsFoundMessage") : Translate("We did not find anything matching your search result"); 342 bool hasSubgroups = false; 343 344 if (productList.SubGroups != null) 345 { 346 hasSubgroups = productList.SubGroups.Any(); 347 } 348 349 if (!Model.Item.GetBoolean("HideNoProductsFoundMessage")) { 350 if (!isVisualEditor) 351 { 352 <div class="alert alert-dark m-0" role="alert"> 353 @noProductsFoundMessage 354 </div> 355 } else { 356 <div class="alert alert-dark m-0" role="alert"> 357 @Translate("Product list: The list will be shown here, if any") 358 </div> 359 } 360 } else if (!hasSubgroups) 361 { 362 <div class="alert alert-dark m-0" role="alert"> 363 @noProductsFoundMessage 364 </div> 365 } 366 } 367 } 368

Sortering

Error executing template "Designs/Swift/Paragraph/Swift_ProductListItemRepeater.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_5dbfd6c2518e46658dcc6372c664cbdd.<RenderProductList>b__1_0(TextWriter __razor_helper_writer) in D:\dynamicweb.net\Solutions\smartpage\vmelektro.cloud.dynamicweb-cms.com\Files\Templates\Designs\Swift\Paragraph\Swift_ProductListItemRepeater.cshtml:line 292
   at CompiledRazorTemplates.Dynamic.RazorEngine_5dbfd6c2518e46658dcc6372c664cbdd.Execute() in D:\dynamicweb.net\Solutions\smartpage\vmelektro.cloud.dynamicweb-cms.com\Files\Templates\Designs\Swift\Paragraph\Swift_ProductListItemRepeater.cshtml:line 40
   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.Core 4 @using Dynamicweb.Ecommerce.CustomerExperienceCenter.Favorites 5 @using Dynamicweb.Environment 6 7 @functions 8 { 9 string liveInfoClass = ""; 10 } 11 12 @{ 13 bool isDetailPage = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("ProductID")); 14 string theme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Theme")) ? " theme " + Model.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : ""; 15 16 string productInfoFeed = ""; 17 bool isLazyLoadingForProductInfoEnabled = Dynamicweb.Ecommerce.DynamicwebLiveIntegration.TemplatesHelper.IsLazyLoadingForProductInfoEnabled; 18 if (isLazyLoadingForProductInfoEnabled) 19 { 20 if (Dynamicweb.Context.Current.Items.Contains("ProductInfoFeed")) 21 { 22 productInfoFeed = Dynamicweb.Context.Current.Items["ProductInfoFeed"]?.ToString(); 23 if (!string.IsNullOrEmpty(productInfoFeed)) 24 { 25 productInfoFeed = $"data-product-info-feed=\"{productInfoFeed}\""; 26 } 27 } 28 liveInfoClass = "js-live-info"; 29 } 30 31 } 32 33 @if (!isDetailPage) { 34 if (!string.IsNullOrEmpty(theme)) { 35 <div class="h-100@(theme) item_@Model.Item.SystemName.ToLower()" @productInfoFeed> 36 @RenderProductList() 37 </div> 38 } else { 39 <div class="item_@Model.Item.SystemName.ToLower()" @productInfoFeed> 40 @RenderProductList() 41 </div> 42 } 43 } 44 45 @helper RenderProductList () { 46 bool isVisualEditor = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("VisualEdit")) ? Convert.ToBoolean(Dynamicweb.Context.Current.Request.QueryString.Get("VisualEdit")) : false; 47 48 ProductListViewModel productList = new ProductListViewModel(); 49 50 string googleAnalyticsTrackingID = Pageview.AreaSettings.GetString("GoogleAnalyticsTrackingID"); 51 string googleAnalyticsMeasurementID = Pageview.AreaSettings.GetString("GoogleAnalyticsMeasurementID"); 52 var cookieOptInLevel = CookieManager.GetCookieOptInLevel(); 53 bool allowTracking = cookieOptInLevel == CookieOptInLevel.All || (cookieOptInLevel == CookieOptInLevel.Functional && CookieManager.GetCookieOptInCategories().Contains("Statistical")); 54 55 ProductListViewModelSettings productListSetting = new ProductListViewModelSettings 56 { 57 LanguageId = Dynamicweb.Ecommerce.Common.Context.LanguageID, 58 CurrencyCode = Dynamicweb.Ecommerce.Common.Context.Currency.Code, 59 CountryCode = Dynamicweb.Ecommerce.Common.Context.Country.Code2, 60 ShopId = Pageview.Area.EcomShopId 61 }; 62 63 int productsCount = 0; 64 int maxProductsCounter = 0; 65 66 if (Dynamicweb.Context.Current.Items.Contains("ProductList")) 67 { 68 productList = (ProductListViewModel)Dynamicweb.Context.Current.Items["ProductList"]; 69 } 70 else if (Pageview.Item["DummyProductGroup"] != null) 71 { 72 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 73 ProductListViewModel groupList = pageViewModel.Item.GetValue("DummyProductGroup") != null ? pageViewModel.Item.GetValue("DummyProductGroup") as ProductListViewModel : new ProductListViewModel(); 74 75 if (groupList?.Group?.Id != null) { 76 productList = ViewModelFactory.CreateView(productListSetting, groupList.Group.Id); 77 Dynamicweb.Context.Current.Items.Add("ProductList", productList); 78 } else { 79 productList = ViewModelFactory.CreateView(productListSetting, Dynamicweb.Ecommerce.Services.ProductGroups.GetGroups(Dynamicweb.Ecommerce.Common.Context.LanguageID).FirstOrDefault().Id); 80 81 Dynamicweb.Context.Current.Items.Add("ProductList", productList); 82 } 83 } 84 else if (Pageview.Item["DummyProductGroup"] == null) { 85 productList = ViewModelFactory.CreateView(productListSetting, Dynamicweb.Ecommerce.Services.ProductGroups.GetGroups(Dynamicweb.Ecommerce.Common.Context.LanguageID).FirstOrDefault().Id); 86 Dynamicweb.Context.Current.Items.Add("ProductList", productList); 87 } 88 89 if (Pageview.Page.Item.SystemName == "Swift_ProductListComponentEdit") { 90 if (productList.TotalProductsCount == 0) { 91 ProductViewModelSettings productSetting = new ProductViewModelSettings 92 { 93 LanguageId = Dynamicweb.Ecommerce.Common.Context.LanguageID, 94 CurrencyCode = Dynamicweb.Ecommerce.Common.Context.Currency.Code, 95 CountryCode = Dynamicweb.Ecommerce.Common.Context.Country.Code2, 96 ShopId = Pageview.Area.EcomShopId 97 }; 98 99 foreach (var product in Dynamicweb.Ecommerce.Services.Products.GetLastActiveProducts(3, Dynamicweb.Ecommerce.Common.Context.LanguageID, false)) { 100 var productView = ViewModelFactory.CreateView(productSetting, product.Id); 101 productList.Products.Add(productView); 102 } 103 104 Dynamicweb.Context.Current.Items["ProductList"] = productList; 105 } 106 107 productList.TotalProductsCount = 3; 108 productList.PageSize = 3; 109 maxProductsCounter = 3; 110 } 111 112 string groupId = productList?.Group?.Id != null ? productList.Group.Id : ""; 113 string url = Dynamicweb.Context.Current.Request.RawUrl; 114 115 if (productList.TotalProductsCount > 0) { 116 int pageSizeSetting = 12; 117 //var productCatalogSettings = new ProductCatalogSettings(Pageview.CurrentParagraph.ModuleProperties); 118 //int pageSizeSetting = productCatalogSettings.PageSize; 119 120 int pageSize = productList.PageSize; 121 pageSize += pageSizeSetting; 122 123 int loadedProducts = productList.PageSize > productList.TotalProductsCount ? productList.TotalProductsCount : productList.PageSize; 124 string searchQuery = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("q")) ? Dynamicweb.Context.Current.Request.QueryString.Get("q") : ""; 125 126 int listItemSourcePageId = Model.Item.GetInt32("ListComponentSource"); 127 var page = Dynamicweb.Services.Pages.GetPage(listItemSourcePageId); 128 129 if (page != null) { 130 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(page); 131 132 string gridColumnSize = Model.Item.GetRawValueString("GridLayoutDesktop", "3-columns"); 133 gridColumnSize = gridColumnSize == "2-columns" ? "g-col-lg-6" : gridColumnSize; 134 gridColumnSize = gridColumnSize == "3-columns" ? "g-col-lg-4" : gridColumnSize; 135 gridColumnSize = gridColumnSize == "4-columns" ? "g-col-lg-3" : gridColumnSize; 136 gridColumnSize = gridColumnSize == "6-columns" ? "g-col-lg-2" : gridColumnSize; 137 gridColumnSize = gridColumnSize == "list" ? "" : gridColumnSize; 138 139 string gridColumnMobileSize = Model.Item.GetRawValueString("GridLayoutMobile", "2-columns"); 140 gridColumnMobileSize = gridColumnMobileSize == "list" ? "g-col-12" : gridColumnMobileSize; 141 gridColumnMobileSize = gridColumnMobileSize == "2-columns" ? "g-col-6" : gridColumnMobileSize; 142 143 string listItemTheme = " theme " + pageViewModel.Item.GetRawValueString("Theme", string.Empty).Replace(" ", "").Trim().ToLower(); 144 string listItemPadding = pageViewModel.Item.GetRawValueString("ContentPadding", string.Empty); 145 string listItemPaddingClass = string.Empty; 146 147 switch(listItemPadding) 148 { 149 case "small": 150 listItemPaddingClass = " p-2 p-xl-3"; 151 break; 152 case "large": 153 listItemPaddingClass = " p-3 p-xl-4"; 154 break; 155 case "small-x": 156 listItemPaddingClass = " px-2 px-md-3"; 157 break; 158 case "large-x": 159 listItemPaddingClass = " px-3 px-md-4"; 160 break; 161 } 162 163 <div class="grid"> 164 @if (!string.IsNullOrWhiteSpace(googleAnalyticsMeasurementID) && allowTracking) 165 { 166 <script> 167 gtag("event", "view_item_list", { 168 item_list_id: "product_list_item_repeater", 169 item_list_name: "Product list (Item Repeater)", 170 items: [ 171 @foreach (ProductViewModel product in productList.Products) 172 { 173 <text>{ 174 item_id: "@product.Number", 175 item_name: "@product.Name", 176 currency: "@product.Price.CurrencyCode", 177 price: @product.Price.Price 178 },</text> 179 } 180 ] 181 }); 182 </script> 183 } 184 185 @foreach (ProductViewModel product in productList.Products) 186 { 187 if (maxProductsCounter == 0 || (productsCount < maxProductsCounter)) { 188 string detailsPageLink = !string.IsNullOrEmpty(GetPageIdByNavigationTag("Shop").ToString()) ? GetPageIdByNavigationTag("Shop").ToString() : string.Empty; 189 string selectedDetailPage = Dynamicweb.Ecommerce.Services.ProductGroups.GetGroup(product.PrimaryOrDefaultGroup.Id)?.Meta.PrimaryPage ?? string.Empty; 190 string detailsPageId = detailsPageLink != string.Empty ? detailsPageLink.Substring(detailsPageLink.LastIndexOf('=') + 1) : string.Empty; 191 string selectedDetailPageId = selectedDetailPage != string.Empty ? selectedDetailPage.Substring(selectedDetailPage.LastIndexOf('=') + 1) : string.Empty; 192 detailsPageId = string.IsNullOrEmpty(selectedDetailPage) ? detailsPageId : selectedDetailPageId; 193 194 string variantIdForLink = !string.IsNullOrEmpty(product.VariantId) ? $"&VariantID={product.VariantId}" : ""; 195 variantIdForLink = string.IsNullOrEmpty(variantIdForLink) && !string.IsNullOrEmpty(product.DefaultVariantId) ? $"&VariantID={product.DefaultVariantId}" : variantIdForLink; 196 197 string link = "Default.aspx?ID=" + GetPageIdByNavigationTag("Shop"); 198 link += $"&GroupID={product.PrimaryOrDefaultGroup.Id}"; 199 link += $"&ProductID={product.Id}"; 200 link += variantIdForLink; 201 link = Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(link); 202 203 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 204 { 205 Dynamicweb.Context.Current.Items["ProductDetails"] = product; 206 } 207 else 208 { 209 Dynamicweb.Context.Current.Items.Add("ProductDetails", product); 210 } 211 212 if (Model.Item.GetString("ListComponentSource") != null) { 213 <article class="@gridColumnMobileSize @gridColumnSize @listItemTheme @listItemPaddingClass d-flex flex-column position-relative product js-product @liveInfoClass" data-product-id="@product.Id" itemscope itemtype="https://schema.org/Product"> 214 @{ 215 string clickProductLink = string.Empty; 216 if (!string.IsNullOrWhiteSpace(googleAnalyticsMeasurementID) && allowTracking) 217 { 218 clickProductLink = "onclick=\"return clickProductLink('" + @product.Id + "', '" + @product.Name + "', '" + @product.VariantName + "', '" + @product.Price.CurrencyCode + "', '" + @product.Price.Price + "')\""; 219 } 220 } 221 <a href="@link" class="stretched-link" @clickProductLink> 222 <span class="visually-hidden">@product.Name</span> 223 </a> 224 @if (!string.IsNullOrWhiteSpace(googleAnalyticsMeasurementID) && allowTracking) 225 { 226 <script> 227 function clickProductLink(productId, productName, productVariant, productCurrency, productPrice) { 228 if (typeof gtag !== "undefined") { 229 gtag("event", "select_item", { 230 item_list_id: "product_list_item_repeater", 231 item_list_name: "Product list (Item Repeater)", 232 items: [ 233 { 234 item_id: productId, 235 item_name: productName, 236 currency: productCurrency, 237 item_list_id: "product_list_item_repeater", 238 item_list_name: "Product list (Item Repeater)", 239 item_variant: productVariant, 240 price: productPrice 241 } 242 ] 243 }); 244 } 245 } 246 </script> 247 } 248 @RenderGrid(listItemSourcePageId) 249 </article> 250 } 251 252 productsCount++; 253 } 254 } 255 </div> 256 257 <div class="my-3"> 258 <div class="text-center"> 259 <div class="opacity-85 mb-3">@loadedProducts @Translate("out of") @productList.TotalProductsCount @Translate("products")</div> 260 @if (productList.PageCount != 1 && maxProductsCounter == 0) { 261 string sortBySelection = Dynamicweb.Context.Current.Request?.Form["SortBy"] ?? "Relevance"; 262 sortBySelection = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("SortBy")) ? Dynamicweb.Context.Current.Request.QueryString.Get("SortBy") : sortBySelection; 263 264 <form method="get" action="@url" data-response-target-element="content" class="w-100"> 265 @if (productList?.FacetGroups != null) { 266 foreach (FacetGroupViewModel facetGroup in productList.FacetGroups) 267 { 268 foreach (FacetViewModel facetItem in facetGroup.Facets) 269 { 270 foreach (FacetOptionViewModel facetOption in facetItem.Options) 271 { 272 if (facetOption.Selected) 273 { 274 <input type="hidden" name="@facetItem.QueryParameter" value="[@facetOption.Value]"> 275 } 276 } 277 } 278 } 279 } 280 281 @if (productList?.Group?.Id != null) { 282 <input type="hidden" name="GroupId" value="@productList.Group.Id"> 283 } 284 285 <input type="hidden" name="PageSize" value="@pageSize"> 286 <input type="hidden" name="SortBy" value="@sortBySelection"> 287 <input type="hidden" name="RequestType" value="UpdateList"> 288 289 @{ 290 string nextPageLink = "/Default.aspx?ID=" + Pageview.Page.ID + "&PageSize=" + pageSize + "&SortBy=" + sortBySelection; 291 292 foreach (FacetGroupViewModel facetGroup in productList.FacetGroups) 293 { 294 foreach (FacetViewModel facetItem in facetGroup.Facets) 295 { 296 foreach (FacetOptionViewModel facetOption in facetItem.Options) 297 { 298 if (facetOption.Selected) 299 { 300 nextPageLink += "&" + facetItem.QueryParameter + "=[" + facetOption.Value + "]"; 301 } 302 } 303 } 304 } 305 306 nextPageLink += productList?.Group?.Id != null ? "&GroupID=" + productList.Group.Id : ""; 307 nextPageLink += !string.IsNullOrEmpty(searchQuery) ? "&q=" + searchQuery : ""; 308 } 309 310 <a href="@nextPageLink" class="btn btn-primary" type="button" onclick="swift.ProductList.Update(event)" id="LoadMoreButton_@Model.ID">@Translate("Load more products")</a> 311 </form> 312 } 313 </div> 314 </div> 315 316 <script> 317 function switchVariantProduct(id, price, imagesrc) { 318 var productImageElement = document.querySelector("#ProductImage_" + id); 319 var productPriceElement = document.querySelector("#ProductPrice_" + id + " .text-price"); 320 321 if (productPriceElement) { 322 productPriceElement.innerText = price; 323 } 324 325 if (productImageElement) { 326 productImageElement.src = imagesrc; 327 328 var imageSrcset = productImageElement.srcset; 329 imageSrcset = imageSrcset.replace(/image=.*?&/g, 'image=' + imagesrc + "&"); 330 331 productImageElement.srcset = imageSrcset; 332 } 333 } 334 </script> 335 } else if (Pageview.IsVisualEditorMode) { 336 <div class="alert alert-dark m-0" role="alert"> 337 <span>@Translate("The selected component does not exist anymore")</span> 338 </div> 339 } 340 } else { 341 string noProductsFoundMessage = !string.IsNullOrEmpty(Model.Item.GetString("NoProductsFoundMessage")) ? Model.Item.GetString("NoProductsFoundMessage") : Translate("We did not find anything matching your search result"); 342 bool hasSubgroups = false; 343 344 if (productList.SubGroups != null) 345 { 346 hasSubgroups = productList.SubGroups.Any(); 347 } 348 349 if (!Model.Item.GetBoolean("HideNoProductsFoundMessage")) { 350 if (!isVisualEditor) 351 { 352 <div class="alert alert-dark m-0" role="alert"> 353 @noProductsFoundMessage 354 </div> 355 } else { 356 <div class="alert alert-dark m-0" role="alert"> 357 @Translate("Product list: The list will be shown here, if any") 358 </div> 359 } 360 } else if (!hasSubgroups) 361 { 362 <div class="alert alert-dark m-0" role="alert"> 363 @noProductsFoundMessage 364 </div> 365 } 366 } 367 } 368

Sortering

Error executing template "Designs/Swift/Paragraph/Swift_ProductListItemRepeater.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_5dbfd6c2518e46658dcc6372c664cbdd.<RenderProductList>b__1_0(TextWriter __razor_helper_writer) in D:\dynamicweb.net\Solutions\smartpage\vmelektro.cloud.dynamicweb-cms.com\Files\Templates\Designs\Swift\Paragraph\Swift_ProductListItemRepeater.cshtml:line 292
   at CompiledRazorTemplates.Dynamic.RazorEngine_5dbfd6c2518e46658dcc6372c664cbdd.Execute() in D:\dynamicweb.net\Solutions\smartpage\vmelektro.cloud.dynamicweb-cms.com\Files\Templates\Designs\Swift\Paragraph\Swift_ProductListItemRepeater.cshtml:line 40
   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.Core 4 @using Dynamicweb.Ecommerce.CustomerExperienceCenter.Favorites 5 @using Dynamicweb.Environment 6 7 @functions 8 { 9 string liveInfoClass = ""; 10 } 11 12 @{ 13 bool isDetailPage = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("ProductID")); 14 string theme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Theme")) ? " theme " + Model.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : ""; 15 16 string productInfoFeed = ""; 17 bool isLazyLoadingForProductInfoEnabled = Dynamicweb.Ecommerce.DynamicwebLiveIntegration.TemplatesHelper.IsLazyLoadingForProductInfoEnabled; 18 if (isLazyLoadingForProductInfoEnabled) 19 { 20 if (Dynamicweb.Context.Current.Items.Contains("ProductInfoFeed")) 21 { 22 productInfoFeed = Dynamicweb.Context.Current.Items["ProductInfoFeed"]?.ToString(); 23 if (!string.IsNullOrEmpty(productInfoFeed)) 24 { 25 productInfoFeed = $"data-product-info-feed=\"{productInfoFeed}\""; 26 } 27 } 28 liveInfoClass = "js-live-info"; 29 } 30 31 } 32 33 @if (!isDetailPage) { 34 if (!string.IsNullOrEmpty(theme)) { 35 <div class="h-100@(theme) item_@Model.Item.SystemName.ToLower()" @productInfoFeed> 36 @RenderProductList() 37 </div> 38 } else { 39 <div class="item_@Model.Item.SystemName.ToLower()" @productInfoFeed> 40 @RenderProductList() 41 </div> 42 } 43 } 44 45 @helper RenderProductList () { 46 bool isVisualEditor = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("VisualEdit")) ? Convert.ToBoolean(Dynamicweb.Context.Current.Request.QueryString.Get("VisualEdit")) : false; 47 48 ProductListViewModel productList = new ProductListViewModel(); 49 50 string googleAnalyticsTrackingID = Pageview.AreaSettings.GetString("GoogleAnalyticsTrackingID"); 51 string googleAnalyticsMeasurementID = Pageview.AreaSettings.GetString("GoogleAnalyticsMeasurementID"); 52 var cookieOptInLevel = CookieManager.GetCookieOptInLevel(); 53 bool allowTracking = cookieOptInLevel == CookieOptInLevel.All || (cookieOptInLevel == CookieOptInLevel.Functional && CookieManager.GetCookieOptInCategories().Contains("Statistical")); 54 55 ProductListViewModelSettings productListSetting = new ProductListViewModelSettings 56 { 57 LanguageId = Dynamicweb.Ecommerce.Common.Context.LanguageID, 58 CurrencyCode = Dynamicweb.Ecommerce.Common.Context.Currency.Code, 59 CountryCode = Dynamicweb.Ecommerce.Common.Context.Country.Code2, 60 ShopId = Pageview.Area.EcomShopId 61 }; 62 63 int productsCount = 0; 64 int maxProductsCounter = 0; 65 66 if (Dynamicweb.Context.Current.Items.Contains("ProductList")) 67 { 68 productList = (ProductListViewModel)Dynamicweb.Context.Current.Items["ProductList"]; 69 } 70 else if (Pageview.Item["DummyProductGroup"] != null) 71 { 72 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 73 ProductListViewModel groupList = pageViewModel.Item.GetValue("DummyProductGroup") != null ? pageViewModel.Item.GetValue("DummyProductGroup") as ProductListViewModel : new ProductListViewModel(); 74 75 if (groupList?.Group?.Id != null) { 76 productList = ViewModelFactory.CreateView(productListSetting, groupList.Group.Id); 77 Dynamicweb.Context.Current.Items.Add("ProductList", productList); 78 } else { 79 productList = ViewModelFactory.CreateView(productListSetting, Dynamicweb.Ecommerce.Services.ProductGroups.GetGroups(Dynamicweb.Ecommerce.Common.Context.LanguageID).FirstOrDefault().Id); 80 81 Dynamicweb.Context.Current.Items.Add("ProductList", productList); 82 } 83 } 84 else if (Pageview.Item["DummyProductGroup"] == null) { 85 productList = ViewModelFactory.CreateView(productListSetting, Dynamicweb.Ecommerce.Services.ProductGroups.GetGroups(Dynamicweb.Ecommerce.Common.Context.LanguageID).FirstOrDefault().Id); 86 Dynamicweb.Context.Current.Items.Add("ProductList", productList); 87 } 88 89 if (Pageview.Page.Item.SystemName == "Swift_ProductListComponentEdit") { 90 if (productList.TotalProductsCount == 0) { 91 ProductViewModelSettings productSetting = new ProductViewModelSettings 92 { 93 LanguageId = Dynamicweb.Ecommerce.Common.Context.LanguageID, 94 CurrencyCode = Dynamicweb.Ecommerce.Common.Context.Currency.Code, 95 CountryCode = Dynamicweb.Ecommerce.Common.Context.Country.Code2, 96 ShopId = Pageview.Area.EcomShopId 97 }; 98 99 foreach (var product in Dynamicweb.Ecommerce.Services.Products.GetLastActiveProducts(3, Dynamicweb.Ecommerce.Common.Context.LanguageID, false)) { 100 var productView = ViewModelFactory.CreateView(productSetting, product.Id); 101 productList.Products.Add(productView); 102 } 103 104 Dynamicweb.Context.Current.Items["ProductList"] = productList; 105 } 106 107 productList.TotalProductsCount = 3; 108 productList.PageSize = 3; 109 maxProductsCounter = 3; 110 } 111 112 string groupId = productList?.Group?.Id != null ? productList.Group.Id : ""; 113 string url = Dynamicweb.Context.Current.Request.RawUrl; 114 115 if (productList.TotalProductsCount > 0) { 116 int pageSizeSetting = 12; 117 //var productCatalogSettings = new ProductCatalogSettings(Pageview.CurrentParagraph.ModuleProperties); 118 //int pageSizeSetting = productCatalogSettings.PageSize; 119 120 int pageSize = productList.PageSize; 121 pageSize += pageSizeSetting; 122 123 int loadedProducts = productList.PageSize > productList.TotalProductsCount ? productList.TotalProductsCount : productList.PageSize; 124 string searchQuery = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("q")) ? Dynamicweb.Context.Current.Request.QueryString.Get("q") : ""; 125 126 int listItemSourcePageId = Model.Item.GetInt32("ListComponentSource"); 127 var page = Dynamicweb.Services.Pages.GetPage(listItemSourcePageId); 128 129 if (page != null) { 130 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(page); 131 132 string gridColumnSize = Model.Item.GetRawValueString("GridLayoutDesktop", "3-columns"); 133 gridColumnSize = gridColumnSize == "2-columns" ? "g-col-lg-6" : gridColumnSize; 134 gridColumnSize = gridColumnSize == "3-columns" ? "g-col-lg-4" : gridColumnSize; 135 gridColumnSize = gridColumnSize == "4-columns" ? "g-col-lg-3" : gridColumnSize; 136 gridColumnSize = gridColumnSize == "6-columns" ? "g-col-lg-2" : gridColumnSize; 137 gridColumnSize = gridColumnSize == "list" ? "" : gridColumnSize; 138 139 string gridColumnMobileSize = Model.Item.GetRawValueString("GridLayoutMobile", "2-columns"); 140 gridColumnMobileSize = gridColumnMobileSize == "list" ? "g-col-12" : gridColumnMobileSize; 141 gridColumnMobileSize = gridColumnMobileSize == "2-columns" ? "g-col-6" : gridColumnMobileSize; 142 143 string listItemTheme = " theme " + pageViewModel.Item.GetRawValueString("Theme", string.Empty).Replace(" ", "").Trim().ToLower(); 144 string listItemPadding = pageViewModel.Item.GetRawValueString("ContentPadding", string.Empty); 145 string listItemPaddingClass = string.Empty; 146 147 switch(listItemPadding) 148 { 149 case "small": 150 listItemPaddingClass = " p-2 p-xl-3"; 151 break; 152 case "large": 153 listItemPaddingClass = " p-3 p-xl-4"; 154 break; 155 case "small-x": 156 listItemPaddingClass = " px-2 px-md-3"; 157 break; 158 case "large-x": 159 listItemPaddingClass = " px-3 px-md-4"; 160 break; 161 } 162 163 <div class="grid"> 164 @if (!string.IsNullOrWhiteSpace(googleAnalyticsMeasurementID) && allowTracking) 165 { 166 <script> 167 gtag("event", "view_item_list", { 168 item_list_id: "product_list_item_repeater", 169 item_list_name: "Product list (Item Repeater)", 170 items: [ 171 @foreach (ProductViewModel product in productList.Products) 172 { 173 <text>{ 174 item_id: "@product.Number", 175 item_name: "@product.Name", 176 currency: "@product.Price.CurrencyCode", 177 price: @product.Price.Price 178 },</text> 179 } 180 ] 181 }); 182 </script> 183 } 184 185 @foreach (ProductViewModel product in productList.Products) 186 { 187 if (maxProductsCounter == 0 || (productsCount < maxProductsCounter)) { 188 string detailsPageLink = !string.IsNullOrEmpty(GetPageIdByNavigationTag("Shop").ToString()) ? GetPageIdByNavigationTag("Shop").ToString() : string.Empty; 189 string selectedDetailPage = Dynamicweb.Ecommerce.Services.ProductGroups.GetGroup(product.PrimaryOrDefaultGroup.Id)?.Meta.PrimaryPage ?? string.Empty; 190 string detailsPageId = detailsPageLink != string.Empty ? detailsPageLink.Substring(detailsPageLink.LastIndexOf('=') + 1) : string.Empty; 191 string selectedDetailPageId = selectedDetailPage != string.Empty ? selectedDetailPage.Substring(selectedDetailPage.LastIndexOf('=') + 1) : string.Empty; 192 detailsPageId = string.IsNullOrEmpty(selectedDetailPage) ? detailsPageId : selectedDetailPageId; 193 194 string variantIdForLink = !string.IsNullOrEmpty(product.VariantId) ? $"&VariantID={product.VariantId}" : ""; 195 variantIdForLink = string.IsNullOrEmpty(variantIdForLink) && !string.IsNullOrEmpty(product.DefaultVariantId) ? $"&VariantID={product.DefaultVariantId}" : variantIdForLink; 196 197 string link = "Default.aspx?ID=" + GetPageIdByNavigationTag("Shop"); 198 link += $"&GroupID={product.PrimaryOrDefaultGroup.Id}"; 199 link += $"&ProductID={product.Id}"; 200 link += variantIdForLink; 201 link = Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(link); 202 203 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 204 { 205 Dynamicweb.Context.Current.Items["ProductDetails"] = product; 206 } 207 else 208 { 209 Dynamicweb.Context.Current.Items.Add("ProductDetails", product); 210 } 211 212 if (Model.Item.GetString("ListComponentSource") != null) { 213 <article class="@gridColumnMobileSize @gridColumnSize @listItemTheme @listItemPaddingClass d-flex flex-column position-relative product js-product @liveInfoClass" data-product-id="@product.Id" itemscope itemtype="https://schema.org/Product"> 214 @{ 215 string clickProductLink = string.Empty; 216 if (!string.IsNullOrWhiteSpace(googleAnalyticsMeasurementID) && allowTracking) 217 { 218 clickProductLink = "onclick=\"return clickProductLink('" + @product.Id + "', '" + @product.Name + "', '" + @product.VariantName + "', '" + @product.Price.CurrencyCode + "', '" + @product.Price.Price + "')\""; 219 } 220 } 221 <a href="@link" class="stretched-link" @clickProductLink> 222 <span class="visually-hidden">@product.Name</span> 223 </a> 224 @if (!string.IsNullOrWhiteSpace(googleAnalyticsMeasurementID) && allowTracking) 225 { 226 <script> 227 function clickProductLink(productId, productName, productVariant, productCurrency, productPrice) { 228 if (typeof gtag !== "undefined") { 229 gtag("event", "select_item", { 230 item_list_id: "product_list_item_repeater", 231 item_list_name: "Product list (Item Repeater)", 232 items: [ 233 { 234 item_id: productId, 235 item_name: productName, 236 currency: productCurrency, 237 item_list_id: "product_list_item_repeater", 238 item_list_name: "Product list (Item Repeater)", 239 item_variant: productVariant, 240 price: productPrice 241 } 242 ] 243 }); 244 } 245 } 246 </script> 247 } 248 @RenderGrid(listItemSourcePageId) 249 </article> 250 } 251 252 productsCount++; 253 } 254 } 255 </div> 256 257 <div class="my-3"> 258 <div class="text-center"> 259 <div class="opacity-85 mb-3">@loadedProducts @Translate("out of") @productList.TotalProductsCount @Translate("products")</div> 260 @if (productList.PageCount != 1 && maxProductsCounter == 0) { 261 string sortBySelection = Dynamicweb.Context.Current.Request?.Form["SortBy"] ?? "Relevance"; 262 sortBySelection = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("SortBy")) ? Dynamicweb.Context.Current.Request.QueryString.Get("SortBy") : sortBySelection; 263 264 <form method="get" action="@url" data-response-target-element="content" class="w-100"> 265 @if (productList?.FacetGroups != null) { 266 foreach (FacetGroupViewModel facetGroup in productList.FacetGroups) 267 { 268 foreach (FacetViewModel facetItem in facetGroup.Facets) 269 { 270 foreach (FacetOptionViewModel facetOption in facetItem.Options) 271 { 272 if (facetOption.Selected) 273 { 274 <input type="hidden" name="@facetItem.QueryParameter" value="[@facetOption.Value]"> 275 } 276 } 277 } 278 } 279 } 280 281 @if (productList?.Group?.Id != null) { 282 <input type="hidden" name="GroupId" value="@productList.Group.Id"> 283 } 284 285 <input type="hidden" name="PageSize" value="@pageSize"> 286 <input type="hidden" name="SortBy" value="@sortBySelection"> 287 <input type="hidden" name="RequestType" value="UpdateList"> 288 289 @{ 290 string nextPageLink = "/Default.aspx?ID=" + Pageview.Page.ID + "&PageSize=" + pageSize + "&SortBy=" + sortBySelection; 291 292 foreach (FacetGroupViewModel facetGroup in productList.FacetGroups) 293 { 294 foreach (FacetViewModel facetItem in facetGroup.Facets) 295 { 296 foreach (FacetOptionViewModel facetOption in facetItem.Options) 297 { 298 if (facetOption.Selected) 299 { 300 nextPageLink += "&" + facetItem.QueryParameter + "=[" + facetOption.Value + "]"; 301 } 302 } 303 } 304 } 305 306 nextPageLink += productList?.Group?.Id != null ? "&GroupID=" + productList.Group.Id : ""; 307 nextPageLink += !string.IsNullOrEmpty(searchQuery) ? "&q=" + searchQuery : ""; 308 } 309 310 <a href="@nextPageLink" class="btn btn-primary" type="button" onclick="swift.ProductList.Update(event)" id="LoadMoreButton_@Model.ID">@Translate("Load more products")</a> 311 </form> 312 } 313 </div> 314 </div> 315 316 <script> 317 function switchVariantProduct(id, price, imagesrc) { 318 var productImageElement = document.querySelector("#ProductImage_" + id); 319 var productPriceElement = document.querySelector("#ProductPrice_" + id + " .text-price"); 320 321 if (productPriceElement) { 322 productPriceElement.innerText = price; 323 } 324 325 if (productImageElement) { 326 productImageElement.src = imagesrc; 327 328 var imageSrcset = productImageElement.srcset; 329 imageSrcset = imageSrcset.replace(/image=.*?&/g, 'image=' + imagesrc + "&"); 330 331 productImageElement.srcset = imageSrcset; 332 } 333 } 334 </script> 335 } else if (Pageview.IsVisualEditorMode) { 336 <div class="alert alert-dark m-0" role="alert"> 337 <span>@Translate("The selected component does not exist anymore")</span> 338 </div> 339 } 340 } else { 341 string noProductsFoundMessage = !string.IsNullOrEmpty(Model.Item.GetString("NoProductsFoundMessage")) ? Model.Item.GetString("NoProductsFoundMessage") : Translate("We did not find anything matching your search result"); 342 bool hasSubgroups = false; 343 344 if (productList.SubGroups != null) 345 { 346 hasSubgroups = productList.SubGroups.Any(); 347 } 348 349 if (!Model.Item.GetBoolean("HideNoProductsFoundMessage")) { 350 if (!isVisualEditor) 351 { 352 <div class="alert alert-dark m-0" role="alert"> 353 @noProductsFoundMessage 354 </div> 355 } else { 356 <div class="alert alert-dark m-0" role="alert"> 357 @Translate("Product list: The list will be shown here, if any") 358 </div> 359 } 360 } else if (!hasSubgroups) 361 { 362 <div class="alert alert-dark m-0" role="alert"> 363 @noProductsFoundMessage 364 </div> 365 } 366 } 367 } 368

Kan du ikke finde dit mærke?

Hvis du ikke kan finde dit mærke på siden her, er der stadig meget stor chance for, at vi enten har din manglende reservedel, eller vi kan skaffe den hurtigt hjem!

Prøv eventuelt at skrive dit mærke i søgefeltet for at finde din manglende reservedel.

Vores kundeservice sidder klar til at hjælpe dig videre. 
Vores telefon er åben fra:
Mandag til torsdag: 08:30 - 16:00.
Fredag: 08:30-14:00

eller kontakt os på mail support@reservedele.nu