Logo
Exception in template (Designs\OT\eCom/Productlist/ProductListPageNoPagination.cshtml): System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.dbdafcdb.Execute()
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context)
   at RazorEngine.Razor.Parse[T](String razorTemplate, T model, String cacheName)
   at Dynamicweb.Rendering.Template.Output()
@inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> @using System; @using System.Web; @using ListeFabrik.CustomModules.Classes; @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> @using System; @using System.Web; @using ListeFabrik.CustomModules; @using ListeFabrik.CustomModules.Classes; @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> @using System; @using System.Web; @using System.Text.RegularExpressions @functions{ public class WrapMethods { //Gets the contrasting color public static string getContrastYIQ(string hexcolor) { if (hexcolor != "") { hexcolor = Regex.Replace(hexcolor, "[^0-9a-zA-Z]+", ""); int r = Convert.ToByte(hexcolor.Substring(0, 2), 16); int g = Convert.ToByte(hexcolor.Substring(2, 2), 16); int b = Convert.ToByte(hexcolor.Substring(4, 2), 16); int yiq = ((r * 299) + (g * 587) + (b * 114)) / 1000; if (yiq >= 128) { return "black"; } else { return "white"; } } else { return "black"; } } //Truncate text public static string Truncate (string value, int count, bool strip=true) { if (strip == true){ value = StripHtmlTagByCharArray(value); } if (value.Length > count) { value = value.Substring(0, count - 1) + "..."; } return value; } //Strip text from HTML public static string StripHtmlTagByCharArray(string htmlString) { char[] array = new char[htmlString.Length]; int arrayIndex = 0; bool inside = false; for (int i = 0; i < htmlString.Length; i++) { char let = htmlString[i]; if (let == '<') { inside = true; continue; } if (let == '>') { inside = false; continue; } if (!inside) { array[arrayIndex] = let; arrayIndex++; } } return new string(array, 0, arrayIndex); } //Make the correct count of columns public static string ColumnMaker(int Col, string ScreenSize) { string Columns = ""; switch (Col) { case 1: Columns = "col-"+ScreenSize+"-12"; break; case 2: Columns = "col-"+ScreenSize+"-6"; break; case 3: Columns = "col-"+ScreenSize+"-4"; break; case 4: Columns = "col-"+ScreenSize+"-3"; break; default: Columns = "col-"+ScreenSize+"-3"; break; } return Columns; } private string Custom(string firstoption, string secondoption) { if (firstoption == "custom") { return secondoption; } else { return firstoption; } } } } @helper GetProductList(dynamic Loop, int ColMD = 3, int ColSM = 3, int ColXS = 1) { var area = Dynamicweb.Content.Area.GetAreaById(Pageview.Area.ID); string searchWords = HttpContext.Current.Request.QueryString["search"]; bool isSearch = searchWords != null; int Count = 0; string ColumnsMD = WrapMethods.ColumnMaker(ColMD, "md"); string ColumnsSM = WrapMethods.ColumnMaker(ColSM, "sm"); string ColumnsXS = WrapMethods.ColumnMaker(ColXS, "xs"); foreach (LoopItem product in Loop) { var standardPrice = product.GetDouble("Ecom:Product.DBPrice"); var customerPrice = product.GetDouble("Ecom:Product.Price.Price"); string perUnitText = "/" + product.GetString("Ecom:Product:Field.ProductUnit"); bool soldByLength = perUnitText == "/M"; var currency = product.GetString("Ecom:Product.Price.Currency.Code"); string Image = product.GetString("Ecom:Product:Field.MainProductImage"); string Picto = product.GetString("Ecom:Product:Field.ProductPictogram"); string GroupLink = product.GetString("Ecom:Product.LinkGroup.Clean"); string Name = product.GetString("Ecom:Product.Name"); string Description = product.GetString("Ecom:Product.ShortDescription"); string Discount = product.GetString("Ecom:Product.Discount.Price"); string Price = product.GetString("Ecom:Product.Price"); string RawPrice = product.GetString("Ecom:Product.Price.PricePIP"); string Filters = product.GetString("Ecom:Product:Field.FilterValues"); string filterClasses = string.Empty; string imagealttext = product.GetString("Ecom:Product:Field.ProductImageAltText"); if (!string.IsNullOrWhiteSpace(Filters)) { filterClasses = "filter-" + Filters.Trim().Replace(",", " filter-"); } if (isSearch) { // If the primary group is not in the current shop, we have to take the group link to the first group that's in the shop // Otherwise DW takes the first group regardless if it belongs to the area or not bool isPrimaryGroupInShop = false; string primaryGroupID = product.GetString("Ecom:Product.PrimaryGroupID"); if (!string.IsNullOrEmpty(primaryGroupID)) { var primaryGroup = Dynamicweb.eCommerce.Products.Group.GetGroupByID(primaryGroupID); isPrimaryGroupInShop = primaryGroup.Shops.Any(x => x.ID == area.EcomShopID); } if (!isPrimaryGroupInShop) { foreach (var loopGroup in product.GetLoop("AssociatedGroups")) { var group = Dynamicweb.eCommerce.Products.Group.GetGroupByID(loopGroup.GetString("Ecom:Group.ID")); if (group.ShopID == area.EcomShopID) { GroupLink = loopGroup.GetString("Ecom:Group.Link.Clean") + "&ProductID=" + product.GetString("Ecom:Product.ID.UrlEncoded"); break; } } } } <div class="productlist grid-item @ColumnsMD @ColumnsSM @ColumnsXS @filterClasses" data-name="@HttpUtility.HtmlEncode(Name.ToLower())" data-price="@RawPrice" data-filter-classes="@filterClasses"> <div class="boxproduct wp-block product"> <div class="listproductright"> <a href="@GroupLink" title="@HttpUtility.HtmlEncode(Name)"> <figure style="" class="productfigure"> @if (!string.IsNullOrEmpty(Image)) { <img alt="@HttpUtility.HtmlEncode(imagealttext)" src="@PIMCommerceUtilities.GetPerfionImageUrl(Image,"150x150")" class="img-responsive img-center"> } </figure> @if (!string.IsNullOrEmpty(Picto)) { <span class="product-picto"><img alt="" src="@PIMCommerceUtilities.GetPerfionImageUrl(Picto, "50x50")" /></span> } </a> </div> <div class="extracolumn"> <h2 class="product-title"><a href="@GroupLink">@Name.Replace("/", " / ")</a></h2> <p>@Translate("Product number", "Product number"): <span>@product.GetString("Ecom:Product.Number")</span></p> </div> <div class="listproductleft wp-block-footer"> @if (customerPrice < standardPrice) { <span class="productprice price pull-right" style=" font-size: 16px !important"><strong>@product.GetString("Ecom:Product.Price.Price")&nbsp;@currency@perUnitText</strong></span><span>&nbsp;&nbsp;</span> <span class="productpricebr"></span> <p class="productoldprice price" style="margin-top: -15px !important; padding-top: 0px !important; color: #AAAAAA !important; font-size: 12px !important; text-align: right; text-decoration: line-through; clear:both;">@standardPrice.ToString("F")&nbsp;@currency@perUnitText</p> } else { <span class="productprice price pull-right" style="font-size: 16px !important"><strong>@product.GetString("Ecom:Product.Price.Price")&nbsp;@currency@perUnitText</strong></span><span>&nbsp;&nbsp;</span> } </div> </div> </div> Count++; if (Count == ColMD) { <div class="row"></div> Count = 0; } } } @{ var subgroups = GetLoop("Subgroups"); } @if (subgroups != null && subgroups.Count > 0) { <div class="row grid main-product-list"> <div id="grouplist"> <div class="col-md-12"> <h1 class="section-title" style="margin-bottom:35px;">@GetString("Ecom:Group.Name")</h1> </div> <div class="group-list-thumbs"> @foreach (var item in subgroups) { <div class="productlist grid-item col-md-3 col-sm-4 col-xs-12 group boxview"> <div class="boxproduct wp-block product"> <div class="listproductright"> <a href='@item.GetString("Ecom:Group.Link.Clean")' title='@item.GetString("Ecom:Group.Name")' class="group-link"> <figure class="productfigure" id="productimgbox"> <img src="@PIMCommerceUtilities.GetPerfionImageUrl(item.GetString("Ecom:Group:Field.CategoryImage.Value"), "251x251")" alt="@item.GetString("Ecom:Group:Field.WebCategoryAltText.Value")" class="group-img img-center" /> </figure> </a> </div> <div class="extracolumn"> <h2 class="group-name product-title"><a href='@item.GetString("Ecom:Group.Link.Clean")' title='@item.GetString("Ecom:Group.Name")' class="group-link">@item.GetString("Ecom:Group.Name").Replace("/", " / ")</a></h2> </div> </div> </div> } </div> </div> </div> } else { string searchWords = HttpContext.Current.Request.QueryString["search"]; bool isSearch = searchWords != null; string grouplink = ""; if (!string.IsNullOrWhiteSpace(GetString("Ecom:ProductList:Page.GroupID"))) { grouplink = "/Default.aspx?ID=" + GetString("Ecom:ProductList:Page.ID") + "&amp;GroupID=" + GetString("Ecom:ProductList:Page.GroupID"); } else { grouplink = "/Default.aspx?ID=" + GetString("Ecom:ProductList:Page.ID") + "&amp;search=" + GetString("Ecom:ProductList:Search.Query"); } var products = GetLoop("Products"); var distinctFilters = (from LoopItem product in products select product.GetString("Ecom:Product:Field.FilterValues").Split(',')).SelectMany(x => x).Distinct(); <div class="row"> <div class="col-md-8 col-sm-8 col-xs-8"> @if (isSearch) { <h3 class="section-title">@searchWords</h3> } else { <h1 class="section-title">@GetString("Ecom:ProductList:Page.GroupName")</h1> <h2>@GetString("Ecom:Group:Field.WebCategoryTextH2.Value")</h2> } </div> <div class="col-md-4 col-sm-4 col-xs-4 pull-right"> <div class="btn-group pull-right hidden-xs" style="" id="viewbtns"> <button type="button" class="btn btn-xs btn-three" onclick="ListView(true)"><span class="glyphicon glyphicon-th-list"></span></button> <button type="button" class="btn btn-xs btn-three" onclick="BoxView(true)"><span class="glyphicon glyphicon-th"></span></button> </div> <div class="pull-right"> <div class="btn-group"> <button type="button" class="btn btn-xs btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false"> @Translate("Sort by", "Sort by") <span class="caret"></span> </button> <ul class="dropdown-menu dropdown-menu-right" role="menu"> <li><a class="pill-left sort-btn" data-sortby="price" data-sortorder="asc">@Translate("Price low-high", "Price low-high")</a></li> <li><a class="pill-left sort-btn" data-sortby="price" data-sortorder="desc">@Translate("Price high-low", "Price high-low")</a></li> </ul> </div> &nbsp;&nbsp; </div> </div> </div> if (!isSearch) { <div class="row"> <div class="col-md-12 group-description"> <article> <p> @GetString("Ecom:Group.Description") </p> </article> </div> </div> <div class="row"> <div class="col-md-12"> <ul class="filters-list"> @foreach (var feature in GetLoop("FilterFeatures")) { int nbFilters = (from LoopItem option in feature.GetLoop("Options") select option.GetString("Option.Value")).Distinct().Count(); if (nbFilters > 1) { var options = feature.GetLoop("Options"); var applicableFilters = options.Count(x => distinctFilters.Contains(x.GetString("Option.Value"))); if (applicableFilters > 1) { <li class="filter button-group" data-filter-group="@feature.GetString("Feature.name")"> <h4>@feature.GetString("Feature.caption")</h4> <ul class="filter-options-list"> <li class="filter-option is-checked" data-filter=""> @Translate("AllFilters", "All") </li> @foreach (var option in options) { if (distinctFilters.Contains(option.GetString("Option.Value"))) { <li class="filter-option" data-filter=".filter-@option.GetString("Option.Value")"> @option.GetString("Option.Label") </li> } } </ul> </li> } } } </ul> </div> </div> } <div class="row grid main-product-list"> @GetProductList(products, 4) </div> <script> @{ string banner = string.Empty; if (!isSearch) { if (string.IsNullOrEmpty(GetString("Ecom:Group:Field.Banner"))) { // if no banner, we take the parent group banner var parents = Dynamicweb.eCommerce.Products.Group.GetGroupByID(GetString("Ecom:Group.ID")).ParentGroups; if (parents.Count > 0) { string parentBanner = parents[0].ProductGroupFieldValues.GetProductGroupFieldValue("Banner").Value.ToString(); if (!string.IsNullOrEmpty(parentBanner)) { banner = PIMCommerceUtilities.GetPerfionImageUrl(parentBanner); } } } else { banner = PIMCommerceUtilities.GetPerfionImageUrl(GetString("Ecom:Group:Field.Banner")); } } } ProductListSettings = { GroupLink: '@grouplink', GroupBanner: '@banner', EcommerceProductListForm: '@Pageview.Area.Item["EcommerceProductListForm"].ToString()', SortSettings: { sortBy: 'original-order' }, IsSearch: @isSearch.ToString().ToLower() }; </script> <script src="/Files/Templates/Designs/Dwsimple/js/pages/productlist.js" defer="defer"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <script src="/Files/Templates/Designs/Dwsimple/js/vendor/readmore.js"></script> <script defer="defer"> $('article').readmore({ speed: 500, collapsedHeight: 60, heightMargin: 16, moreLink: '<a class="btn btn btn-sm btn-dw-secondary" href="#">Læs mere</a>', lessLink: '<a class="btn btn btn-sm btn-dw-secondary" href="#">Luk</a>', }); </script> }
Cookies

Dette website bruger cookies til statistik og til at levere den bedste brugeroplevelse til dig
Du kan altid slette cookies i din browsers indstillinger.  Læs mere

Accepter ikke cookies Accepter kun funktions cookies Accepter alle cookies