Vinterens bestselgere!

3X Workwear - TOR

Holdbart og komfortabelt

Se kolleksjonen

NYHET!

Gaustatoppen Fleece

Nå resirkulert!

Gaustatoppen

Gaustatoppen

BESTSELGERE

VERNEUTSTYR

Siste sjanse

Error executing template "Designs/Swift/Paragraph/Swift_ProductComponentSlider.cshtml"
System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
   at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
   at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
   at Dynamicweb.Ecommerce.Prices.PriceManager.GetPrice(PriceContext context, Product product, String unitId, Int64 stockLocationId)
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at Dynamicweb.Ecommerce.ProductCatalog.ViewEngine.<>c__DisplayClass3_2.<BulkCreateView>b__48()
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at Dynamicweb.Ecommerce.ProductCatalog.ViewEngine.GetPrice(PriceViewModelSettings settings, IList`1 products, Boolean& pricesHasBeenPrepared, Object lock, Lazy`1 priceInfo)
   at Dynamicweb.Ecommerce.ProductCatalog.ViewEngine.<>c__DisplayClass3_2.<BulkCreateView>b__49()
   at Dynamicweb.Ecommerce.ProductCatalog.ViewModelPropertyFiller`1.Fill[S](T model, String propertyName, Func`1 source)
   at Dynamicweb.Ecommerce.ProductCatalog.ViewEngine.BulkCreateView(ProductViewModelSettings settings, Boolean isRecursive, IList`1 products)
   at Dynamicweb.Ecommerce.ProductCatalog.ViewModelPropertyFiller`1.Fill[S](T model, String propertyName, Func`1 source)
   at Dynamicweb.Ecommerce.ProductCatalog.ViewEngine.CreateView(ProductListViewModelSettings settings, IList`1 products)
   at Dynamicweb.Ecommerce.ProductCatalog.ViewEngine.CreateView(ProductListViewModelSettings settings, Group group, IList`1 products)
   at Dynamicweb.Ecommerce.Content.Items.Editors.ProductCatalogEditor.GetViewModelValue(Object value)
   at System.Lazy`1.CreateValue()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Lazy`1.get_Value()
   at Dynamicweb.Frontend.ItemFieldViewModel.GetValue[T]()
   at Dynamicweb.Frontend.ItemViewModel.GetValue[T](String systemName)
   at CompiledRazorTemplates.Dynamic.RazorEngine_0fd268fcf7ad4ee7a18eb7b2d794123d.Execute()
   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.Core 3 @using Dynamicweb.Ecommerce.ProductCatalog 4 5 @{ 6 ProductViewModel product = null; 7 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 8 { 9 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 10 } 11 else if (Pageview.Page.Item["DummyProduct"] != null && Pageview.IsVisualEditorMode) 12 { 13 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 14 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 15 16 if (productList?.Products is object) 17 { 18 product = productList.Products[0]; 19 } 20 } 21 22 string layout = Model.Item.GetRawValueString("Layout") == "slider" ? "ProductSliderComponent" : "ProductGridComponent"; 23 string lazyHeight = Model.Item.GetBoolean("SetMinHeightForLazyLoading") ? "min-height: 360px" : ""; 24 string theme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Theme")) ? " theme " + Model.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : ""; 25 26 //Link generation 27 string pageId = Model.Item.GetLink("ProductSliderServicePage") != null ? Model.Item.GetLink("ProductSliderServicePage").PageId.ToString() : ""; 28 string servicePageByNavigationTag = GetPageIdByNavigationTag("ProductSliderService") != 0 ? GetPageIdByNavigationTag("ProductSliderService").ToString() : ""; 29 pageId = pageId == "" ? servicePageByNavigationTag : pageId; 30 31 string url = "/Default.aspx?ID=" + pageId; 32 33 if (Pageview.IsVisualEditorMode) 34 { 35 url += "&VisualEdit=True"; 36 } 37 38 bool isLazyLoadingForProductInfoEnabled = Dynamicweb.Core.Converter.ToBoolean(Dynamicweb.Context.Current.Items["IsLazyLoadingForProductInfoEnabled"]); 39 if (isLazyLoadingForProductInfoEnabled) 40 { 41 url += "&getproductinfo=true"; 42 } 43 44 url += $"&ProductListPartial={layout}"; //Use this to render either a slider or a grid 45 46 //Source type 47 string sourceType = Model.Item.GetRawValueString("RelationType", "trending"); 48 IList<string> relateFromProductIds = new List<string> { }; 49 IList<string> relateFromProductVariantIds = new List<string> { }; 50 IList<string> relateFromGroupIds = new List<string> { }; 51 bool hasVariants = false; 52 53 ProductListViewModel relateToViewModel = Model.Item.GetValue<ProductListViewModel>("RelateTo"); 54 55 //--- PRODUCTS --- 56 if (sourceType == "variants" || sourceType == "frequently" || sourceType == "selected") 57 { 58 if (relateToViewModel?.Products != null) 59 { 60 hasVariants = relateToViewModel.Products.Any(p => !string.IsNullOrEmpty(p.VariantId)); 61 foreach (var fromProduct in relateToViewModel.Products) 62 { 63 if (hasVariants) 64 { 65 if (!string.IsNullOrEmpty(fromProduct.VariantId)) 66 { 67 relateFromProductVariantIds.Add($"{fromProduct.Id} {fromProduct.VariantId}"); 68 } 69 else 70 { 71 relateFromProductVariantIds.Add($"{fromProduct.Id}"); 72 } 73 } 74 relateFromProductIds.Add($"{fromProduct.Id}"); 75 } 76 } 77 } 78 79 //--- GROUPS --- 80 if (sourceType == "most-sold" || sourceType == "trending" || sourceType == "latest" || sourceType == "custom") 81 { 82 var groupsToRelateTo = Model.Item.GetString("RelateTo").Split(',').ToList(); 83 84 foreach (var fromGroup in groupsToRelateTo) 85 { 86 var groupId = fromGroup.Length > 2 ? fromGroup.Remove(0, 2) : fromGroup; 87 88 if (!fromGroup.Contains("p_")) 89 { 90 relateFromGroupIds.Add(groupId); 91 } 92 } 93 94 if (relateToViewModel?.Products != null) 95 { 96 foreach (var fromProduct in relateToViewModel.Products) 97 { 98 var groupId = fromProduct.PrimaryOrDefaultGroup.Id; 99 relateFromGroupIds.Add(groupId); 100 } 101 } 102 } 103 104 105 //Create group id collection and products id collection strings 106 string productIds = relateFromProductIds.Count > 0 ? string.Join(",", relateFromProductIds) : ""; 107 string productVariantIds = relateFromProductVariantIds.Count > 0 ? string.Join(",", relateFromProductVariantIds) : ""; 108 string groupIds = relateFromGroupIds.Count > 0 ? string.Join(",", relateFromGroupIds) : ""; 109 110 if (product is object) 111 { 112 if (string.IsNullOrEmpty(productIds) && (sourceType == "variants" || sourceType == "frequently" || sourceType == "selected" || sourceType == "custom")) 113 { 114 productIds = product.Id; 115 } 116 117 if (string.IsNullOrEmpty(groupIds) && (sourceType == "most-sold" || sourceType == "trending" || sourceType == "latest")) 118 { 119 groupIds = product.PrimaryOrDefaultGroup.Id; 120 } 121 } 122 } 123 124 @*Container element for the request*@ 125 @if (!string.IsNullOrEmpty(productIds) || !string.IsNullOrEmpty(groupIds) || (string.IsNullOrEmpty(productIds) && string.IsNullOrEmpty(groupIds))) 126 { 127 <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()"> 128 <input type="hidden" name="ParagraphId" value="@Model.ID" /> 129 <input type="hidden" name="SortOrder" value="DESC"> 130 <input type="hidden" name="SourceType" value="@sourceType"> 131 132 @if (!string.IsNullOrEmpty(groupIds)) 133 { 134 <input type="hidden" name="GroupId" value="@groupIds"> 135 } 136 @if (sourceType != "frequently" && !string.IsNullOrEmpty(productIds) && !hasVariants) 137 { 138 <input type="hidden" name="MainProductId" value="@productIds"> 139 } 140 @if (sourceType != "frequently" && hasVariants) 141 { 142 <input type="hidden" name="ProductVariantId" value="@productVariantIds"> 143 } 144 145 @if (Model.Item.GetInt32("ProductsCount") != 0) 146 { 147 <input type="hidden" name="PageSize" value="@Model.Item.GetInt32("ProductsCount")"> 148 } 149 150 @if (sourceType == "variants") 151 { 152 <input type="hidden" name="isVariant" value="true"> 153 } 154 @if (sourceType == "most-sold") 155 { 156 <input type="hidden" name="SortBy" value="OrderCount"> 157 } 158 @if (sourceType == "trending") 159 { 160 <input type="hidden" name="SortBy" value="OrderCountGrowth"> 161 } 162 @if (sourceType == "frequently" && !string.IsNullOrEmpty(productIds)) 163 { 164 <input type="hidden" name="BoughtWithProductIds" value="[@productIds]"> 165 } 166 @if (sourceType == "latest") 167 { 168 <input type="hidden" name="SortBy" value="Created"> 169 } 170 </form> 171 172 <script type="module" src="/Files/Templates/Designs/Swift/Assets/js/swiffy-slider.js"></script> 173 <script type="module"> 174 swift.AssetLoader.Load('/Files/Templates/Designs/Swift/Assets/css/swiffy-slider.min.css', 'css'); 175 </script> 176 177 <div class="w-100 h-100@(theme)"> 178 <div id="@Model.ID" class="user-select-none" style="scroll-margin-top:var(--header-height,150px)"></div> 179 <div id="ComponentSliderProducts_@Model.ID" class="h-100" style="@lazyHeight"></div> 180 </div> 181 182 <script type="module"> 183 const productSliderContainer = document.querySelector("#ComponentSliderProducts_@Model.ID"); 184 const productSliderForm = document.querySelector("#ComponentSliderProductsForm_@Model.ID"); 185 186 swift.PageUpdater.Update(productSliderForm); 187 productSliderForm.addEventListener("updated.swift.pageupdater", function(e){ 188 if (e.detail.html === "") { 189 productSliderContainer.closest("[data-col-size]").classList.add("d-none"); 190 } 191 }); 192 </script> 193 } 194 else if (Pageview.IsVisualEditorMode == true) 195 { 196 <div class="alert alert-dark" role="alert"> 197 <span>@Translate("Product component slider: The slider will be rendered here, if there is anything to show")</span> 198 </div> 199 } 200

Usikker på hvilke vernesko du trenger?

Les mer om verneklasser

Våre merker

Ved å klikke "Godta alle" samtykker du i at vi kan samle inn informasjon om deg til ulike formål, inkludert: funksjonalitet, statistikk og markedsføring