
| REAL DESIGN
Error executing template "Designs/BocaBearings/eCom/Productlist/genericProductList.cshtml" System.NullReferenceException: Object reference not set to an instance of an object. at CompiledRazorTemplates.Dynamic.RazorEngine_9e9209abc3fc4195a011845a41e37668.<>c__DisplayClass33_0.<CreateTable>b__0(TextWriter __razor_helper_writer) in f:\Domains\Sites\bocabearings.com\Files\Templates\Designs\BocaBearings\eCom\Productlist\genericProductList.cshtml:line 1300 at CompiledRazorTemplates.Dynamic.RazorEngine_9e9209abc3fc4195a011845a41e37668.<>c__DisplayClass32_0.<RenderMakesOptions>b__0(TextWriter __razor_helper_writer) in f:\Domains\Sites\bocabearings.com\Files\Templates\Designs\BocaBearings\eCom\Productlist\genericProductList.cshtml:line 1212 at CompiledRazorTemplates.Dynamic.RazorEngine_9e9209abc3fc4195a011845a41e37668.Execute() in f:\Domains\Sites\bocabearings.com\Files\Templates\Designs\BocaBearings\eCom\Productlist\genericProductList.cshtml:line 1169 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 @using System.Collections; 2 @using System.Data; 3 @using Dynamicweb.Core 4 @using Dynamicweb.Ecommerce.Products; 5 @using Dynamicweb.Environment; 6 @using System.IO; 7 @using System.Web; 8 @using System.Text; 9 @using System.Text.RegularExpressions; 10 @using Dynamicweb.Environment; 11 12 @functions { 13 public List<LoopItem> getFacetOptions(string facetName) { 14 List<LoopItem> facetOptions = null; 15 foreach(var t in GetLoop("FacetGroups")) { 16 var fct = t.GetLoop("Facets").FirstOrDefault(f => f.GetString("Facet.Field") == facetName); 17 if(fct != null) { 18 facetOptions = fct.GetLoop("FacetOptions"); 19 break; 20 } 21 } 22 return facetOptions; 23 } 24 25 public static string GetFirstUserGroupID(int[] userGroupIds, List<string> productPricesGroups) 26 { 27 var userFirstGroup = ""; 28 foreach (var userGroupId in userGroupIds) 29 { 30 var userGroup = Dynamicweb.Security.UserManagement.Group.GetGroupByID(userGroupId); 31 if (!productPricesGroups.Contains(userGroup.ToString())) continue; 32 userFirstGroup = userGroup.ToString(); 33 break; 34 } 35 return userFirstGroup; 36 } 37 38 public string RenderParentEcomNav(Dynamicweb.Ecommerce.Products.Group group) 39 { 40 if (group.ParentGroupsDefaultLanguage != null && group.ParentGroupsDefaultLanguage.Count > 0) 41 { 42 string parent_id = group.ParentGroupsDefaultLanguage[0].Id; 43 Dynamicweb.Ecommerce.Products.Group parent = Dynamicweb.Ecommerce.Products.Group.GetGroupById(parent_id); 44 if (parent != null) 45 { 46 return RenderParentEcomNav(parent); 47 } 48 } 49 return group.Id; 50 } 51 public static string GetImage(string str_source, int num_width, int num_height, int num_widthTablet = 0, int num_heightTablet = 0, int num_widthMobile = 0, int num_heightMobile = 0, string str_format = "", int num_compression = 0, int num_crop = 5) 52 { 53 Dynamicweb.Frontend.PageView obj_currentPageview = Dynamicweb.Frontend.PageView.Current(); 54 string str_currDevice = obj_currentPageview.Device.ToString(); 55 string str_alternativeImage = obj_currentPageview.Area.Item["NoImage"] != null ? obj_currentPageview.Area.Item["NoImage"].ToString() : "/Files/Templates/Designs/BocaBearings/images/alternativeImage.jpg"; 56 57 string str_width = ""; 58 string str_height = ""; 59 int num_getImageWidth = num_width != 0 ? num_width : 0; 60 int num_getImageHeight = num_height != 0 ? num_height : 0; 61 string str_getImageFormat = str_format != "" ? "&Format=" + str_format : ""; 62 string str_getImageCompression = num_compression != 0 ? "&Compression=" + num_compression : ""; 63 64 if (str_currDevice == Dynamicweb.Frontend.Devices.DeviceType.Tablet.ToString()) 65 { 66 num_getImageWidth = num_widthTablet != 0 ? num_widthTablet : num_getImageWidth; 67 num_getImageHeight = num_heightTablet != 0 ? num_heightTablet : num_getImageHeight; 68 } 69 else if (str_currDevice == Dynamicweb.Frontend.Devices.DeviceType.Mobile.ToString()) 70 { 71 num_getImageWidth = num_widthMobile != 0 ? num_widthMobile : num_getImageWidth; 72 num_getImageHeight = num_heightMobile != 0 ? num_heightMobile : num_getImageHeight; 73 } 74 75 if (num_getImageWidth != 0) 76 { 77 str_width = "&Width=" + num_getImageWidth; 78 } 79 if (num_getImageHeight != 0) 80 { 81 str_height = "&Height=" + num_getImageHeight; 82 } 83 84 string str_output = "/Admin/Public/GetImage.ashx?Image=" + str_source + str_width + str_height + "&altFmImage_path=" + str_alternativeImage + str_getImageFormat + str_getImageCompression + "&Crop=" + num_crop; 85 return str_output; 86 } 87 88 static readonly string[] SizeSuffixes = { "bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" }; 89 90 static string SizeSuffix(Int64 value) 91 { 92 if (value < 0) { return "-" + SizeSuffix(-value); } 93 94 int i = 0; 95 decimal dValue = (decimal)value; 96 while (Math.Round(dValue / 1024) >= 1) 97 { 98 dValue /= 1024; 99 i++; 100 } 101 102 return string.Format("{0:n1} {1}", dValue, SizeSuffixes[i]); 103 } 104 105 public static string GetFriendlyUrl(int num_pageId) 106 { 107 var output = Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(num_pageId); 108 return output; 109 } 110 111 public static object GetParagraph(int num_paragraphId) 112 { 113 var paragraphService = new Dynamicweb.Content.ParagraphService(); 114 var output = paragraphService.GetParagraph(num_paragraphId); 115 return output; 116 } 117 118 public static string StripHtml(string source) 119 { 120 return Regex.Replace(source, "<.*?>", string.Empty); 121 } 122 123 public static string GetRequest(string str_param = "") 124 { 125 string str_output = Dynamicweb.Context.Current.Request.QueryString[str_param]; 126 return str_output; 127 } 128 129 public static string GetParam(string str_param = "") 130 { 131 string str_output = Dynamicweb.Context.Current.Request.Params[str_param]; 132 return str_output; 133 } 134 135 public static void AddCookie(string str_name = "", string str_value = "") 136 { 137 var obj_cookie = new Dynamicweb.Environment.Cookie(str_name); 138 obj_cookie.Value = str_value; 139 Dynamicweb.Context.Current.Response.Cookies.Add(obj_cookie); 140 } 141 142 public static void RemoveCookie(string str_name = "") 143 { 144 var obj_cookie = new Dynamicweb.Environment.Cookie(str_name); 145 obj_cookie.Expires = DateTime.Now.AddDays(-1d); 146 Dynamicweb.Context.Current.Response.Cookies.Add(obj_cookie); 147 } 148 149 public static string GetCookie(string str_name = "") 150 { 151 string str_output = ""; 152 if(Dynamicweb.Context.Current.Request.Cookies[str_name] != null ){ 153 str_output = Dynamicweb.Context.Current.Request.Cookies[str_name].Value; 154 } 155 return str_output; 156 } 157 158 public static bool ExistCookie(string str_name = "") 159 { 160 bool bol_output = false; 161 if(Dynamicweb.Context.Current.Request.Cookies[str_name] != null ){ 162 bol_output = true; 163 } 164 return bol_output; 165 } 166 167 public static void Redirect(string str_url = "") 168 { 169 Dynamicweb.Context.Current.Response.Redirect(Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(str_url)); 170 } 171 /*example: Redirect("/Default.aspx?ID=12")*/ 172 173 public static IHtmlString EncodeJS(string input) 174 { 175 StringBuilder builder = new StringBuilder(); 176 // Open the double quotes 177 builder.Append("\""); 178 // Then add each character properly escaping them 179 foreach (char c in input) 180 { 181 switch (c) 182 { 183 //First check whether it's one of the defined escape sequences 184 case '\'': //single quote 185 builder.Append("\\\'"); 186 break; 187 case '\"': //double quote 188 builder.Append("\\\""); 189 break; 190 case '\\': //backslash 191 builder.Append("\\\\"); 192 break; 193 case '\0': //Unicode character 0 194 builder.Append("\\0"); 195 break; 196 case '\a': //Alert (character 7) 197 builder.Append("\\a"); 198 break; 199 case '\b': //Backspace (character 8) 200 builder.Append("\\b"); 201 break; 202 case '\f': //Form feed (character 12) 203 builder.Append("\\f"); 204 break; 205 case '\n': //New line (character 10) 206 builder.Append("\\n"); 207 break; 208 case '\r': //Carriage return (character 13) 209 builder.Append("\\r"); 210 break; 211 case '\t': //Horizontal tab (character 9) 212 builder.Append("\\t"); 213 break; 214 case '\v': //Vertical quote (character 11) 215 builder.Append("\\v"); 216 break; 217 default: 218 // If it's none of the defined escape sequences, convert the character to an int and check the code 219 int i = (int)c; 220 if (i >= 32 && i <= 127) 221 { 222 // if it's a displayable ASCII character, just write the character 223 builder.Append(c); 224 } 225 else 226 { 227 // otherwise write the Unicode escape sequence for the character with hex value 228 builder.AppendFormat("\\u{0:X04}", i); 229 } 230 break; 231 } 232 } 233 // Close the double quotes 234 builder.Append("\""); 235 // You have to return an IHtmlString otherwise an HTML escape will be performed e.g. < will be replaced by < 236 return new HtmlString(builder.ToString()); 237 } 238 239 } 240 @using Dynamicweb.Environment; 241 242 @functions{ 243 public string RenderDimensions(string dimension){ 244 245 return dimension; 246 247 if(!string.IsNullOrEmpty(dimension)){ 248 string dimensionClean = dimension; 249 string[] cleanUpDictionary = {"Metric","Inch","es","Millimeters"," "}; 250 251 foreach(string dictionary in cleanUpDictionary){ 252 dimensionClean = dimensionClean.Replace(dictionary,""); 253 } 254 dimensionClean = dimensionClean.ToLower(); 255 string[] dimensions = (dimensionClean ?? "").Split(new [] { 'x' },StringSplitOptions.RemoveEmptyEntries); 256 if(dimensions.Any()){ 257 dimensionClean =""; 258 foreach(string d in dimensions){ 259 var dimensionDouble = Double.Parse(d); 260 var hasDecimals = (int)dimensionDouble != dimensionDouble; 261 string str_d = hasDecimals ? dimensionDouble.ToString("#,##0.0000") : dimensionDouble.ToString("#,##0"); 262 dimensionClean = dimensionClean + " x " + str_d ; 263 } 264 dimensionClean = dimensionClean.Substring(3); 265 } 266 return dimensionClean; 267 268 } 269 270 } 271 272 273 } 274 @helper RenderMakes(List<LoopItem> makes,Dictionary<string, string> products,bool isBrowseAll) 275 { 276 string currentUrl = Dynamicweb.Context.Current.Request.Url.AbsolutePath; 277 278 foreach (string qp in Dynamicweb.Context.Current.Request.QueryString.AllKeys) 279 { 280 if(!qp.Equals("ItemMakes") && !qp.Equals("ItemModels") && !qp.Equals("ItemFeatures")) 281 { 282 currentUrl += String.Format("{0}{1}={2}", currentUrl.Contains("?") ? "&" : "?", qp, Dynamicweb.Context.Current.Request.QueryString[qp]); 283 } 284 } 285 286 Dictionary<string, List<LoopItem>> groupedDictionary = null; 287 288 if(makes != null) { 289 groupedDictionary = makes.GroupBy(g => g.GetString("FacetOption.Value").Substring(0, 1)).ToDictionary(g => g.Key, g => g.ToList()); 290 } 291 else { 292 List<LoopItem> dummyList = new List<LoopItem>(); 293 groupedDictionary = new Dictionary<string, List<LoopItem>>(); 294 foreach(string s in products.Keys){ 295 string key = s.Substring(0, 1); 296 297 if(!groupedDictionary.ContainsKey(key)){ 298 groupedDictionary.Add(key, dummyList); 299 } 300 } 301 } 302 303 if(makes != null && makes.Any() || products != null && products.Any()) { 304 List<string> specialChars = new List<string>(new string[] { "#", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" }); 305 string specialCharsClass = "inactive"; 306 foreach (string item in groupedDictionary.Keys) 307 { 308 if (specialChars.Contains(item)) 309 { 310 specialCharsClass = "active"; 311 break; 312 } 313 } 314 <div class="row"> 315 <div class="col-xs-12 "> 316 <ul id="ABC-filter" class="hidden-xs"> 317 <li><a href="javascript:void(0);" class="@specialCharsClass" data-filter="0-9">@Translate("0-9", "0-9")</a></li> 318 @for (char c = 'A'; c <= 'Z'; c++) 319 { 320 string letter = c.ToString(), 321 liClass = groupedDictionary.ContainsKey(letter) ? "active" : "inactive"; 322 <li><a href="javascript:void(0);" class="@liClass" data-filter="@letter">@letter</a></li> 323 } 324 </ul> 325 </div> 326 </div> 327 <div class="row"> 328 <div class="col-xs-12"> 329 <ul class="ModelsList"> 330 @if(makes != null) 331 { 332 foreach (var letter in groupedDictionary.OrderBy(p => p.Key)) 333 { 334 string firstLetter = specialChars.Contains(letter.Key) ? "0-9" : letter.Key; 335 <li data-a="aaaa"> 336 <h3 class="h1" data-filter="@firstLetter">@letter.Key.ToUpper()</h3> 337 <div class="row"> 338 @foreach (LoopItem product in letter.Value.OrderBy(p => p.GetString("FacetOption.Value"))) 339 { 340 string currentItemMakeEncoded = product.GetString("FacetOption.Value").Replace(",","|").Replace(" ", "_").Replace("'","*"); 341 <div class="col-xs-12 col-sm-4 col-md-3"> 342 <a href="/@currentUrl&ItemMakes=@currentItemMakeEncoded">@product.GetString("FacetOption.Value").Replace("|", ",").Replace("_", " ").Replace("*", "'").ToUpper()</a> 343 </div> 344 } 345 </div> 346 </li> 347 } 348 } 349 else { 350 foreach (var letter in groupedDictionary) 351 { 352 string firstLetter = specialChars.Contains(letter.Key) ? "0-9" : letter.Key; 353 var keys = products.Keys.Where(x => x.Substring(0,1) == letter.Key); 354 keys = keys.Distinct().ToList(); 355 <li> 356 <h3 class="h1" data-filter="@firstLetter">@letter.Key</h3> 357 <div class="row"> 358 @foreach(var key in keys) { 359 string make = String.IsNullOrEmpty(Dynamicweb.Context.Current.Request["ItemMakes"]) ? "" : Dynamicweb.Context.Current.Request["ItemMakes"].ToString(); 360 string[] modelFeature = key.Split('|'); 361 string url = String.Format("{0}&ItemMakes={1}&ItemModels={2}&ItemFeatures={3}", currentUrl, make, modelFeature[0].Replace(",","|").Replace(" ", "_").Replace("'","*"),modelFeature[1].Replace(",","|").Replace(" ", "_").Replace("'","*")); 362 <div class="col-xs-12 col-sm-4 col-md-3"> 363 <a href="@url">@key.Replace("_"," ").Replace("*","'")</a> 364 </div> 365 } 366 </div> 367 </li> 368 } 369 } 370 </ul> 371 </div> 372 </div> 373 } 374 else { 375 <h2>@Translate("noProductsAvailable","No products available.")</h2> 376 } 377 } 378 379 @helper RenderPriceContainer(LoopItem product,Dynamicweb.Content.Items.Item item) { 380 List<LoopItem> productPrices = product.GetLoop("Product.Prices"); 381 string str_productID = product.GetString("Ecom:Product.ID"); 382 bool bol_userLogged = Dynamicweb.Security.UserManagement.User.IsExtranetUserLoggedIn(); 383 string userGroupID = (!bol_userLogged) ? (item["Retail"] ?? "").ToString() : GetFirstUserGroupID(Pageview.User.GroupsIds.ToArray(), productPrices.Select(p => p.GetString("Ecom:Product.Prices.GroupID")).Distinct().ToList()); 384 string str_urlReq = "/Default.aspx?ID=" + item["RequestQuote"].ToString() + "&prodID=" + str_productID; 385 List<LoopItem> lst_quantityPrices = productPrices.Where(x => x.GetString("Ecom:Product.Prices.GroupID") == userGroupID && x.GetInteger("Ecom:Product.Prices.Quantity") < 100).OrderByDescending(p => p.GetInteger("Ecom:Product.Prices.Quantity")).ToList(); 386 string containerClass = lst_quantityPrices.Any() ? "quantityContainer" : "noMultiplePrice"; 387 string priceTitle = lst_quantityPrices.Any() ? Translate("listPrice") : Translate("yourPrice"); 388 <div class="col-xs-12 col-sm-4"> 389 <div class="qty-pricing"> 390 <div id="@containerClass" class="col-xs-12 noPadding"> 391 <ul> 392 <li class="list-price"><span class="col-xs-5 noPadding" data-price='@product.GetValue("Ecom:Product.Price")'> @priceTitle</span><span class="col-xs-7 whiteText priceSize_0">@product.GetValue("Ecom:Product.Price")</span></li> 393 @if(lst_quantityPrices.Any()) { 394 List<string> lst_quantityPricesOrdered = new List<string>(); 395 int lastQuantity = 100, 396 numPrices = lst_quantityPrices.Count - 1; 397 398 foreach (LoopItem price in lst_quantityPrices) 399 { 400 int _quantity = price.GetInteger("Ecom:Product.Prices.Quantity"); 401 _quantity = _quantity == 0 ? 1 : _quantity; 402 403 string htmlResult = "<li class=whiteBG><span class=\"blackTextImportant col-sm-5 col-xs-6 noPaddingLeft\">" + Translate("Qty", "Qty") + " " + _quantity + " - " + (lastQuantity - 1) + "</span><span class=\"col-sm-7 col-xs-6 greenTextImportant priceSize_" + numPrices + "\">" + price.GetString("Ecom:Product.Prices.PriceWithoutVATFormatted") + "</span></li>"; 404 405 lst_quantityPricesOrdered.Add(htmlResult); 406 407 numPrices--; 408 lastQuantity = price.GetInteger("Ecom:Product.Prices.Quantity"); 409 } 410 lst_quantityPricesOrdered.Reverse(); 411 412 <li class="your-price"><span class="col-xs-5 noPadding"> Your Price</span><span class="col-xs-7 whiteText priceSize_0">@product.GetValue("Ecom:Product.Price")</span></li> 413 foreach (string liHtml in lst_quantityPricesOrdered) 414 { 415 @liHtml 416 } 417 418 <li> 419 <span class="pull-left col-sm-5 col-xs-6 noPaddingLeft">@Translate("Qty", "Qty") @Translate("100+", "100 +")</span> 420 <a class="min-btn btn-blue generalButton underline pull-right" href="@str_urlReq">@Translate("requestQuote", "Request Quote")</a> 421 </li> 422 } 423 424 </ul> 425 </div> 426 </div> 427 </div> 428 } 429 430 @helper CheckStock(Dynamicweb.Content.Items.Item item,string str_productID,string str_productVariantID,LoopItem product) { 431 var inquirePage = (item["InquireAboutAvailability"] ?? "").ToString(); 432 var miniCartPage = (Pageview.Area.Item["MiniCart"] ?? "").ToString(); 433 434 <form name="addToCart" class="col-xs-12 col-sm-2 noPaddingLeft" action="@miniCartPage" method="post"> 435 <input type="hidden" name="cartcmd" value="add"/> 436 <input type="hidden" name="productID" value="@str_productID"/> 437 <input type="hidden" name="variantID" value="@str_productVariantID"/> 438 <input type="hidden" name="redirect" value="false"/> 439 440 <div class="cart-controls pull-right"> 441 @if (product.GetInteger("Ecom:Product.Stock") > 0) 442 { 443 <span class="qty-label">Qty</span> 444 <input class="quantity" name="Quantity" type="number" value="1" maxlength="4" min="1"/> 445 <br/> 446 } 447 </div> 448 <div class="cart-controls text-right"> 449 @if (product.GetInteger("Ecom:Product.Stock") > 0) 450 { 451 <a class="addToCart generalButton pull-right addToCartSubmit addToCartTracking"> @Translate("Add to Cart")</a> //CUSTOM CODE - removed icon 452 } 453 else 454 { 455 <a rel="nofollow" class="btn-softBlue pull-right inquireAboutAvailability" href="/Default.aspx?ID=@inquirePage&prodID=@str_productID"><i class="fa fa-comment fa-2x"></i> @Translate("Inquire")</a> 456 } 457 </div> 458 </form> 459 } 460 461 @helper CheckStock_(Dynamicweb.Content.Items.Item item,string str_productID,string str_productVariantID,LoopItem product) { 462 string inquirePage = (item["InquireAboutAvailability"] ?? "").ToString(); 463 string str_myMiniCart = (Pageview.Area.Item["MiniCart"] ?? "").ToString(); 464 <form class="col-xs-12 col-sm-2 noPaddingLeft"> 465 <input type="hidden" name="cartcmd" value="add"/> 466 <input type="hidden" name="productid" value="@str_productID"/> 467 <input type="hidden" name="variantID" value="@str_productVariantID"/> 468 @* added to allow post to Minicart and Facebook Tracking *@ 469 <input type="hidden" name="ID" value="@str_myMiniCart"/> 470 <div class="cart-controls pull-right"> 471 @if(product.GetInteger("Ecom:Product.Stock") > 0){ 472 <span class="qty-label">Qty</span> 473 <input class="quantity" name="Quantity" type="number" value="1" maxlength="4" min="1"/><br/> 474 } 475 </div> 476 <div class="cart-controls text-right"> 477 @if(product.GetInteger("Ecom:Product.Stock") > 0){ 478 <button class="addToCart generalButton pull-right addToCartTracking" type="submit"> 479 <i class="fa fa-shopping-cart"></i> @Translate("Add to Cart") 480 </button> 481 } 482 else 483 { 484 485 <a rel="nofollow" class="btn-softBlue pull-right inquireAboutAvailability" href="/Default.aspx?ID=@inquirePage&prodID=@str_productID"><i class="fa fa-comment fa-2x"></i> @Translate("Inquire")</a> 486 } 487 </div> 488 </form> 489 } 490 491 492 493 @functions{ 494 bool haveKits; 495 } 496 497 @{ 498 var itemArea = Pageview.Area.Item; 499 List<LoopItem> facetGroups = GetLoop("FacetGroups"); 500 501 int num_currPage = GetInteger("Ecom:ProductList.CurrentPage"); 502 int page_size = GetInteger("Ecom:ProductList.PageSize"); 503 int num_totalPages = GetInteger("Ecom:ProductList.TotalPages"); 504 505 var products = GetLoop("Products"); 506 string groupID = GetString("Ecom:Group.ID"), parentGroup = "", 507 make = String.IsNullOrEmpty(Dynamicweb.Context.Current.Request["ItemMakes"]) ? "" : Dynamicweb.Context.Current.Request["ItemMakes"].ToString().Replace("-"," "), 508 model = String.IsNullOrEmpty(Dynamicweb.Context.Current.Request["ItemModels"]) ? "" : Dynamicweb.Context.Current.Request["ItemModels"].ToString().Replace("-"," "), 509 feature = String.IsNullOrEmpty(Dynamicweb.Context.Current.Request["ItemFeatures"]) ? "" : Dynamicweb.Context.Current.Request["ItemFeatures"].ToString().Replace("-"," "), 510 prodType = String.IsNullOrEmpty(Dynamicweb.Context.Current.Request["ProductType"]) ? "" : Dynamicweb.Context.Current.Request["ProductType"].ToString(), 511 makesTitle = String.IsNullOrEmpty(Dynamicweb.Context.Current.Request["ItemMakes"]) ? Translate("chooseMakes","Choose your Manufacturer") : Translate("chooseModel","Choose your Model"), 512 query = ""; 513 514 @* Snippet Section *@ 515 string productPageId = itemArea["ProductPage"] != null ? itemArea["ProductPage"].ToString() : ""; 516 string prodTypes = Dynamicweb.Context.Current.Request["ProductType"] != null ? Dynamicweb.Context.Current.Request["ProductType"].ToString() : ""; 517 string isMakeActives = (prodTypes.Equals("2") || String.IsNullOrEmpty(prodTypes)) && Dynamicweb.Context.Current.Request["loadseries"] == null ? "active" : "", 518 isSeriesActive = isMakeActives.Equals("") && Dynamicweb.Context.Current.Request["searchSize"] == null && GetLoop("Childgroups").Where(x => x.GetBoolean("Ecom:Group.ShowInMenu")).ToList().Any() && !GetBoolean("Ecom:Group:Field.NoSubgroups") && String.IsNullOrEmpty(model) && String.IsNullOrEmpty(feature) ? "active" : "", 519 isSizeActives = isSeriesActive.Equals("") && prodTypes.Equals("0") ? "active" : ""; 520 521 if(Dynamicweb.Context.Current.Request["loadResults"] != null){ 522 isSeriesActive = ""; 523 isSizeActives = "active"; 524 } 525 526 string searchByMakesModelsLink = !prodType.Equals("2") ? String.Format("/Default.aspx?ID={0}&groupId={1}&ProductType=2",productPageId,groupID) : "javascript:void(0)"; 527 string searchBySizesLink = !prodType.Equals("0") ? String.Format("/Default.aspx?ID={0}&groupId={1}&ProductType=0&searchSize=true",productPageId,groupID) : "javascript:void(0)"; 528 529 if(!String.IsNullOrEmpty(groupID)) { 530 Dynamicweb.Ecommerce.Products.Group actualGroup = Dynamicweb.Ecommerce.Products.Group.GetGroupById(groupID); 531 parentGroup = RenderParentEcomNav(actualGroup); 532 } 533 bool first = true; 534 535 536 List<LoopItem> productsList = products.Where(x => x.GetString("Ecom:Product.Type") != "2").ToList(); 537 List<LoopItem> productsListKits = products.Where(x => x.GetString("Ecom:Product.Type") == "2").ToList(); 538 haveKits = productsListKits.Any(); 539 540 541 int productCount = GetBoolean("Ecom:Group:Field.Multipack") ? productsListKits.Count : productsList.Count; 542 int startValue = ((num_currPage - 1) * page_size) + 1; 543 int toValue = page_size * num_currPage; 544 int total = GetInteger("Ecom:ProductList.PageProdCnt");//(page_size * num_totalPages); 545 546 if(productCount < page_size){ 547 toValue = total; 548 } 549 550 string classDiv = "col-md-12"; 551 552 foreach(var parameter in GetLoop("Query.Parameters")) { 553 string parameterName = parameter.GetString("Parameter.Name"); 554 string parameterValue = parameter.GetString("Parameter.Value"); 555 if(!String.IsNullOrEmpty(parameterValue) && !parameterName.Equals("GroupID") && !parameterName.Equals("ParentID")) { 556 query += "&" + parameterName + "=" + parameterValue; 557 } 558 } 559 } 560 561 @* Show models and sizes (products that are not kits) *@ 562 @if (products != null && products.Any()) 563 { 564 if(GetBoolean("Ecom:Group:Field.Multipack") || (!haveKits && productsList.Any())){ 565 classDiv = "col-md-10"; 566 var lst_parameters = GetLoop("Query.Parameters"); 567 string str_parentID = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.Params["parentID"]) ? Dynamicweb.Context.Current.Request.Params["parentID"].ToString() : ""; 568 string str_prodtype = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.Params["ProductType"]) ? Dynamicweb.Context.Current.Request.Params["ProductType"].ToString() : ""; 569 ArrayList composedFacets = new ArrayList(); 570 composedLabels = new Dictionary<string, string>(); 571 composedLabels.Add("equal", Translate("equalTo", "Equal to")); 572 composedLabels.Add("lower", Translate("lessTo", "Less or Equal to")); 573 composedLabels.Add("greater", Translate("greaterTo", "Greater or Equal to")); 574 Dynamicweb.Ecommerce.Products.Group currGroup = Dynamicweb.Ecommerce.Products.Group.GetGroupById(GetString("Ecom:Group.ID")); 575 string parent = currGroup != null ? RenderParentEcomNav(currGroup) : ""; 576 bool isMultipack = GetBoolean("Ecom:Group:Field.Multipack") && str_prodtype.Equals("2"); 577 List<LoopItem> filteredFacetGroups = isMultipack ? facetGroups.Where(fg => fg.GetString("FacetGroup.Name").Equals("Multipack.facets")).ToList() : facetGroups.Where(fg => !fg.GetString("FacetGroup.Name").Equals("Multipack.facets")).ToList(); 578 579 <div id="filtersContainer" class="col-xs-12 col-md-2 noPadding"> 580 <div class="green-heading"> @*CUSTOM CODE - orange to green heading*@ 581 <h2>@Translate("filterHeading", "Filter Your Results")</h2> 582 </div> 583 <form id="filtersForm" class="left-search_filter filtersBody"> @*CUSTOM CODE - custom helper*@ 584 <input type="hidden" name="loadResults" value="true"/> 585 <!-- <input type="hidden" name="parentID" value="@str_parentID"/> --> 586 <input type="hidden" name="ProductType" value="@str_prodtype"/> 587 @foreach(LoopItem fg in filteredFacetGroups) 588 { 589 var facets = fg.GetLoop("Facets"); 590 591 @* Do not show Makes/Models/Features in bearing and ball types tree *@ 592 if(parent.Equals("L1BEARINGBALLTYPES")) { 593 facets = facets.Where(x => x.GetString("Facet.Name") != "Makes" && x.GetString("Facet.Name") != "Models" && x.GetString("Facet.Name") != "Features").ToList(); 594 } 595 string groupName = fg.GetString("FacetGroup.Name"); 596 var count = facets.Sum(x => x.GetInteger("Facet.OptionWithResultCount")); 597 598 foreach (LoopItem i in facets) 599 { 600 bool facetAdded = false; 601 var parameters = lst_parameters.Where(x => x.GetString("Parameter.Name") == i.GetString("Facet.QueryParameter")).FirstOrDefault(); 602 string str_parameterType = parameters != null ? parameters.GetString("Parameter.Type") : ""; 603 string str_templateOutput = "string"; 604 605 if((i.GetString("Facet.QueryParameter") == "P_Id_equal" || i.GetString("Facet.QueryParameter") == "P_DimensionType" ) && !hasHighlightedFilters /*&& !isMultipack*/){ 606 hasHighlightedFilters = true; 607 @:<div class="highlightedFilters"> 608 @RenderSnippet("DimensionType") 609 } 610 611 if(str_parameterType.Contains("[]")){ 612 switch (i.GetString("Facet.Name")) 613 { 614 case "Applications": 615 str_templateOutput = "selectApplications"; 616 break; 617 case "Bearing Types": 618 str_templateOutput = "selectBearingTypes"; 619 break; 620 case "Models": 621 str_templateOutput = "selectModel"; 622 break; 623 case "Features": 624 str_templateOutput = "selectFeature"; 625 break; 626 case "fieldName": 627 str_templateOutput = "multiselect"; 628 break; 629 case "fieldName2": 630 str_templateOutput = "checkboxes"; 631 break; 632 default: 633 str_templateOutput = "select"; 634 break; 635 } 636 } 637 else if(str_parameterType.Contains("Boolean")){ 638 switch (i.GetString("Facet.Name")) 639 { 640 case "fieldName": 641 str_templateOutput = "select"; 642 break; 643 case "fieldName2": 644 str_templateOutput = "radio"; 645 break; 646 default: 647 str_templateOutput = "checkbox"; 648 break; 649 } 650 } 651 else if(i.GetInteger("Facet.OptionWithResultCount") > 0) { 652 string facetName = i.GetString("Facet.Name"); 653 string facetField = i.GetString("Facet.Field"); 654 string parameter = i.GetString("Facet.QueryParameter"); 655 var options = i.GetLoop("FacetOptions").Where(x => x.GetString("FacetOption.Value") != "0").ToList(); 656 if(facetName.Contains("Composed") && options.Any() ) { 657 string[] facetSplit = facetName.Split('_'); 658 string param = parameter.Substring(0,parameter.LastIndexOf("_")); 659 string s = facetName.Substring(0,facetName.LastIndexOf("_")); 660 661 var filtered = facets.Where(f => f.GetString("Facet.Field").Contains(facetField)).ToList(); 662 if(!composedFacets.Contains(s)) { 663 composedFacets.Add(s); 664 facetAdded = true; 665 } 666 667 if (facetAdded && filtered.Any()) 668 { 669 @createOptions(filtered,param,facetSplit[1],options, i.GetString("Facet.Type").Equals("Term")) 670 } 671 672 <input type="hidden" name="@parameter" value="" disabled /> 673 } 674 else { 675 switch (i.GetString("Facet.Name")) 676 { 677 case "fieldName3": 678 str_templateOutput = "multiselect"; 679 break; 680 case "DimensionType": 681 //str_templateOutput = "hidden"; 682 str_templateOutput = "select"; 683 break; 684 default: 685 str_templateOutput = "select"; 686 break; 687 } 688 } 689 } 690 else if(i.GetString("Facet.Field").Contains("Weight_Options")) { 691 string facetName = i.GetString("Facet.Name"); 692 string facetField = i.GetString("Facet.Field"); 693 string parameter = i.GetString("Facet.QueryParameter"); 694 var options = i.GetLoop("FacetOptions"); 695 if(facetName.Contains("Composed")) { 696 string[] facetSplit = facetName.Split('_'); 697 string param = parameter.Substring(0,parameter.LastIndexOf("_")); 698 string s = facetName.Substring(0,facetName.LastIndexOf("_")); 699 700 var filtered = facets.Where(f => f.GetString("Facet.Field").Contains(facetField)).ToList(); 701 if(!composedFacets.Contains(s)) { 702 composedFacets.Add(s); 703 facetAdded = true; 704 } 705 706 if (facetAdded && filtered.Any()) 707 { 708 @createOptions(filtered,param,facetSplit[1],options, i.GetString("Facet.Type").Equals("Term")) 709 } 710 711 <input type="hidden" name="@parameter" value="" disabled /> 712 } 713 } 714 else { 715 switch (i.GetString("Facet.Name")) 716 { 717 case "fieldName": 718 str_templateOutput = "autocomplete"; 719 break; 720 case "Stock": 721 str_templateOutput = "stockCheck"; 722 break; 723 case "Fitments": 724 str_templateOutput = "hidden"; 725 break; 726 default: 727 str_templateOutput = "select"; 728 break; 729 } 730 731 } 732 if(!i.GetString("Facet.Name").Contains("Composed")) { 733 @field(i, str_parameterType, str_templateOutput) 734 } 735 736 if(i.GetString("Facet.QueryParameter") == "P_Width_greater" && hasHighlightedFilters /*&& !isMultipack*/){ 737 @:</div> 738 } 739 } 740 } 741 742 <a href="@Dynamicweb.Context.Current.Request.RawUrl.Split('?')[0].ToString()" class="btn-green generalButton applyFilter">@Translate("reset", "Reset")</a> @*CUSTOM CODE - Green Button*@ 743 744 </form> 745 </div> 746 747 @helper field(LoopItem i , string str_parameterType, string str_templateOutput ) { 748 string str_parameter = i.GetString("Facet.QueryParameter"); 749 string str_name = i.GetString("Facet.Name"); 750 bool isTerm = i.GetString("Facet.Type").Equals("Term"); 751 List<LoopItem> facetOptions = i.GetLoop("FacetOptions").Where(x => x.GetString("FacetOption.Value") != "0").ToList(); 752 var isSingleFacetOption = facetOptions.Count == 1; 753 var isDimensionType = i.GetString("Facet.Name") == "DimensionType"; 754 755 756 switch (str_templateOutput) 757 { 758 case "stockCheck": 759 bool isChecked = !String.IsNullOrEmpty(Dynamicweb.Context.Current.Request["Stock"]) && Dynamicweb.Context.Current.Request["Stock"].ToString().Equals("0"); 760 <fieldset class="col-xs-12 noPadding" data-type="@str_parameterType"> 761 <legend class="h3 bold col-xs-8 noPadding">@Translate("inStock","In Stock Only"):</legend> 762 <input checked="@isChecked" type="checkbox" id="inStock" value="-1" name="Stock"/> 763 </fieldset> 764 break; 765 766 case "multiselect": 767 if(facetOptions.Any()) { 768 <fieldset class="col"> 769 <legend class="h3 bold">@str_name.Replace("_"," "):</legend> 770 <select data-size="8" name="@str_parameter" multiple> 771 <option value="">@Translate("all","All")</option> 772 @foreach(LoopItem option in facetOptions.OrderBy(o => o.GetInteger("FacetOption.Label"))) 773 { 774 bool bol_checked = option.GetBoolean("FacetOption.Selected"); 775 string str_value = option.GetString("FacetOption.Value"); 776 string str_nameOption = option.GetString("FacetOption.Name"); 777 string str_label = isTerm ? str_value : option.GetString("FacetOption.Label"); 778 779 <option selected="@bol_checked" value="@str_value">@str_label.Replace("_"," ")</option> 780 } 781 </select> 782 </fieldset> 783 } 784 break; 785 786 case "checkboxes": 787 if(facetOptions.Any()) { 788 <fieldset class="col-xs-12 noPadding" data-type="@str_parameterType"> 789 <legend class="h3 bold">@str_name.Replace("_"," ") :</legend> 790 <div class="filtersContainer hide"> 791 @foreach(LoopItem option in facetOptions.Where(f => f.GetInteger("FacetOption.Count") != 0).OrderByDescending(o => o.GetInteger("FacetOption.Count")).ThenBy(or => or.GetString("FacetOption.Label"))) 792 { 793 bool bol_checked = option.GetBoolean("FacetOption.Selected"); 794 string str_value = option.GetString("FacetOption.Value"); 795 string str_nameOption = option.GetString("FacetOption.Name"); 796 string str_label = isTerm ? str_value : option.GetString("FacetOption.Label"); 797 <label><input checked="@bol_checked" type="checkbox" value="@str_value" name="@str_parameter"> @str_label (@option.GetString("FacetOption.Count"))</label> 798 } 799 </div> 800 </fieldset> 801 } 802 break; 803 case "selectFeature": 804 case "select": 805 if(facetOptions.Any()) 806 { 807 if (isDimensionType) 808 { 809 @:@SnippetStart("DimensionType") 810 } 811 string facetOption = GetQueryParameter(str_parameter); 812 813 <fieldset class="col-xs-12 noPadding"> 814 <legend class="h3 bold">@str_name.Replace("_"," "):</legend> 815 <select data-size="8" name="@str_parameter" @string.Format("{0}", isSingleFacetOption ? "class=\"singleFacetOption\"" : string.Empty)> 816 <option value="">@Translate("all","All")</option> 817 @foreach(LoopItem option in facetOptions.OrderByDescending(o => o.GetInteger("FacetOption.Label"))) 818 { 819 string str_value = option.GetString("FacetOption.Value"); 820 string str_nameOption = option.GetString("FacetOption.Name"); 821 string str_label = isTerm ? str_value : option.GetString("FacetOption.Label"); 822 bool isSelected = str_value == facetOption; 823 <option selected="@isSelected" value="@str_value">@str_label.Replace("_"," ")</option> 824 } 825 </select> 826 </fieldset> 827 if (isDimensionType) 828 { 829 @:@SnippetEnd("DimensionType") 830 } 831 } 832 break; 833 834 case "selectApplications": 835 case "selectBearingTypes": 836 string currApp = Dynamicweb.Context.Current.Request["ParentID"] != null ? Dynamicweb.Context.Current.Request["ParentID"].ToString() : ""; 837 string defaultApp = ""; 838 string defaultType = "L2-RADIALB"; 839 if (str_name.ToLower().Contains("application")) 840 { 841 currApp = !String.IsNullOrEmpty(currApp) ? currApp : defaultApp; 842 } 843 else 844 { 845 currApp = !String.IsNullOrEmpty(currApp) ? currApp : defaultType; 846 } 847 848 if (facetOptions.Any()) 849 { 850 Dictionary<string, string> allGroups = GetAllApplications(String.Format("'{0}'", String.Join("','", facetOptions.Select(fo => fo.GetString("FacetOption.Value")).Distinct().ToArray()))); 851 <fieldset class="col-xs-12 noPadding sameFilter"> 852 <legend class="h3 bold">@str_name:</legend> 853 <select data-size="8" name="@str_parameter" @string.Format("{0}", isSingleFacetOption ? "class=\"singleFacetOption\"" : string.Empty)> 854 <option value="">All</option> 855 @foreach (LoopItem option in facetOptions) 856 { 857 string appValue = option.GetString("FacetOption.Value").ToUpper(), 858 appLabel = allGroups.ContainsKey(appValue) ? allGroups[appValue] : option.GetString("FacetOption.Name"); 859 bool appIsChecked = currApp == appValue; 860 <option selected="@appIsChecked" value="@appValue">@appLabel</option> 861 } 862 </select> 863 </fieldset> 864 } 865 break; 866 867 case "selectModel": 868 string currentModel = ""; 869 List<string> models = new List<string>(); 870 871 if (!String.IsNullOrEmpty(Dynamicweb.Context.Current.Request["ItemMakes"]) && !String.IsNullOrEmpty(Dynamicweb.Context.Current.Request["ParentID"])) 872 { 873 string make = Dynamicweb.Context.Current.Request["ItemMakes"].ToString(); 874 currentModel = (Dynamicweb.Context.Current.Request["ItemModels"] ?? "").ToString(); 875 models = GetModels((Dynamicweb.Context.Current.Request["ParentID"] ?? "").ToString(), make.Replace("|", ",").Replace("_", " ").Replace("*", "'")); 876 } 877 878 var isSingleModelOption = models.Count == 1; 879 880 <fieldset class="col-xs-12 noPadding"> 881 <legend class="h3 bold">@str_name:</legend> 882 <select data-size="8" name="@str_parameter" @string.Format("{0}", isSingleModelOption ? "class=\"singleFacetOption\"" : string.Empty)> 883 <option value="">All</option> 884 @foreach (string modelOption in models) 885 { 886 var isSelected = modelOption.Replace(",", "|").Replace(" ","_").Replace("'", "*").Equals(currentModel); 887 <option selected="@isSelected" value="@(modelOption.Replace(",", "|").Replace(" ","_").Replace("'", "*"))">@modelOption</option> 888 } 889 </select> 890 </fieldset> 891 break; 892 /*case "___selectFeature": 893 <fieldset class="col-xs-12 noPadding"> 894 <legend class="h3 bold">@str_name:</legend> 895 <select data-size="8" name="@str_parameter"> 896 <option value="">All</option> 897 @if(!String.IsNullOrEmpty(Dynamicweb.Context.Current.Request["ItemMakes"]) && !String.IsNullOrEmpty(Dynamicweb.Context.Current.Request["ParentID"])) { 898 string make = Dynamicweb.Context.Current.Request["ItemMakes"].ToString(); 899 string model = (Dynamicweb.Context.Current.Request["ItemModels"] ?? "").ToString(); 900 string currentFeature = (Dynamicweb.Context.Current.Request["ItemFeatures"] ?? "").ToString(); 901 List<string> features = GetFeatures(make,model.Replace("|", ",").Replace("_"," ").Replace("*","'")); 902 bool isSelected = false; 903 foreach (string featureOption in features) 904 { 905 isSelected = featureOption.Replace(",", "|").Replace(" ","_").Equals(currentFeature); 906 <option selected="@isSelected" value="@(featureOption.Replace(",", "|").Replace(" ","_"))">@featureOption</option> 907 } 908 } 909 </select> 910 </fieldset> 911 break;*/ 912 913 914 case "checkbox": 915 if(facetOptions.Any()) { 916 <fieldset data-type="@str_parameterType"> 917 @foreach(LoopItem option in facetOptions.Where(f => f.GetInteger("FacetOption.Count") != 0).OrderByDescending(o => o.GetInteger("FacetOption.Count")).ThenBy(or => or.GetString("FacetOption.Label"))) 918 { 919 bool bol_checked = option.GetBoolean("FacetOption.Selected"); 920 string str_value = option.GetString("FacetOption.Value") == "True" ? "True" : ""; 921 string str_nameOption = option.GetString("FacetOption.Name"); 922 923 if(str_value == "True") { 924 <legend class="h3 bold">@str_name.Replace("_"," "):</legend> 925 <div class="filtersContainer hide"> 926 <label><input checked="@bol_checked" type="checkbox" value="@str_value" name="@str_parameter"> @str_name (@option.GetString("FacetOption.Count"))</label> 927 </div> 928 } 929 } 930 </fieldset> 931 } 932 break; 933 934 case "radio": 935 break; 936 937 case "radios": 938 break; 939 940 case "autocomplete": 941 break; 942 943 case "text": 944 <fieldset class="col-xs-12 noPadding" data-name="@str_name"> 945 <legend class="h3 bold">@str_name.Replace("_"," "):</legend> 946 <input type="text" name="@str_parameter" /> 947 </fieldset> 948 break; 949 950 case "textComposed": 951 <fieldset class="col-xs-12 noPadding composedSet" data-name="@str_name"> 952 <legend class="h3 bold">@str_name.Replace("_"," "):</legend> 953 <input class="composed" type="text" name="@str_name" /> 954 </fieldset> 955 break; 956 957 case "hidden": 958 <fieldset class="col-xs-12 noPadding hidden" data-name="@str_name"> 959 <legend class="h3 bold">@str_name:</legend> 960 <input type="hidden" name="@str_parameter" id="@str_parameter" value="" /> 961 </fieldset> 962 break; 963 964 default: 965 <fieldset class="col-xs-12 noPadding" data-type="@str_parameterType"> 966 <legend class="h3 bold">@str_name.Replace("_"," "):</legend> 967 <div class="filtersContainer"> 968 <input type="text" name="@str_parameter" value="" /> 969 </div> 970 </fieldset> 971 break; 972 } 973 } 974 975 @functions { 976 System.Collections.Specialized.NameValueCollection allRequestParams = Dynamicweb.Context.Current.Request.Params; 977 Dictionary<string, string> composedLabels; 978 bool hasHighlightedFilters = false; 979 980 public string GetQueryParameter(string queryParameter) { 981 return (Dynamicweb.Context.Current.Request[queryParameter] ?? "").ToString(); 982 } 983 } 984 @functions{ 985 public Dictionary<string, string> GetAllApplications(string filterGroups) 986 { 987 Dictionary<string, string> groups = new Dictionary<string, string>(); 988 DataSet allGroups = Dynamicweb.Data.Database.CreateDataSet("SELECT GroupID, GroupName FROM EcomGroups WHERE GroupID IN (" + filterGroups + ")"); 989 990 if (allGroups.Tables.Count > 0 && allGroups.Tables[0].Rows.Count > 0) 991 { 992 foreach (DataRow group in allGroups.Tables[0].Rows) 993 { 994 string groupID = (group["GroupID"] ?? "").ToString(), 995 groupName = (group["GroupName"] ?? "").ToString(); 996 997 if (!String.IsNullOrWhiteSpace(groupID) && !String.IsNullOrWhiteSpace(groupName) && !groups.ContainsKey(groupID)) groups.Add(groupID, groupName); 998 } 999 } 1000 return groups; 1001 } 1002 public List<string> GetModels(string parentGroupID, string make) { 1003 List<string> modelNames = new List<string>(); 1004 using (var s = Dynamicweb.Data.Database.CreateConnection()) 1005 { 1006 var cmd = s.CreateCommand(); 1007 cmd.CommandText = "SELECT DISTINCT m_mf.Model FROM ItemType_Make_ModelAnd_Features m_mf INNER JOIN ItemType_Fitments f ON CHARINDEX(m_mf.id, f.Fits) > 0 and f.Product_ID IN (SELECT ProductID FROM EcomProducts WHERE ProductID IN (SELECT DISTINCT GroupProductRelationProductID from EcomGroupProductRelation WHERE GroupProductRelationGroupID IN (SELECT GroupRelationsGroupID FROM EcomGroupRelations WHERE GroupRelationsParentID=@application OR GroupRelationsParentID IN (SELECT GroupRelationsGroupID FROM EcomGroupRelations WHERE GroupRelationsParentID=@application)))) WHERE m_mf.Make=@make"; 1008 1009 cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter() 1010 { 1011 ParameterName = "application", 1012 SqlDbType = System.Data.SqlDbType.NVarChar, 1013 Value = parentGroupID 1014 }); 1015 1016 cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter() 1017 { 1018 ParameterName = "make", 1019 SqlDbType = System.Data.SqlDbType.NVarChar, 1020 Value = make 1021 }); 1022 var reader = cmd.ExecuteReader(); 1023 while(reader.Read()) 1024 { 1025 modelNames.Add(reader["Model"].ToString()); 1026 } 1027 s.Close(); 1028 } 1029 return modelNames; 1030 } 1031 } 1032 @functions 1033 { 1034 public string FormatDimension(string dimension) 1035 { 1036 if (string.IsNullOrEmpty(dimension)) return string.Empty; 1037 if (!double.TryParse(dimension, out var dimensionValue)) return string.Empty; 1038 1039 var dimensionFormatted = dimension.Contains(".") ? dimensionValue.ToString("#,##0.0000") : dimensionValue.ToString("#,##0"); 1040 return dimensionFormatted; 1041 } 1042 } 1043 1044 @helper createOptions(List<LoopItem> facets, string name, string title, List<LoopItem> facetOptions, bool isTerm) 1045 { 1046 1047 string currentFacetParam = "", selectedFilter = "", selectedOption = ""; 1048 1049 foreach(string k in allRequestParams.AllKeys) 1050 { 1051 if(k.StartsWith(String.Format("{0}_", name))) 1052 { 1053 currentFacetParam = k; 1054 selectedFilter = k.Replace(String.Format("{0}_", name), ""); 1055 selectedOption = allRequestParams[k].ToString(); 1056 break; 1057 } 1058 } 1059 1060 <fieldset class="col-xs-12 noPadding composedSet" data-name="@name"> 1061 <legend class="h3 bold">@title:</legend> 1062 @if (facetOptions != null && facetOptions.Any()) 1063 { 1064 string[] dimensionIDs = {"P_Id","P_Od","P_Width"}; 1065 bool isDimension = dimensionIDs.Any(d => d.Contains(name)); 1066 var optionsSorted = facetOptions.Where(x => x.GetString("FacetOption.Value") != "0").OrderBy(x => x.GetDouble("FacetOption.Value")); 1067 <select data-size="8" class="composed" @isDimension> 1068 <option value="">@Translate("all","All")</option> 1069 @foreach (LoopItem o in optionsSorted) 1070 { 1071 string optionValue = String.Format("{0}", isTerm ? o.GetString("FacetOption.Value") : o.GetString("FacetOption.Label")); 1072 1073 if (isDimension) { 1074 var dimensionValue = FormatDimension(optionValue); 1075 optionValue = !string.IsNullOrEmpty(dimensionValue) ? dimensionValue : optionValue; 1076 } 1077 1078 <option selected="@(selectedOption == o.GetString("FacetOption.Value"))" value="@(o.GetString("FacetOption.Value"))"> 1079 @optionValue 1080 </option> 1081 } 1082 </select> 1083 } 1084 else 1085 { 1086 <input class="composed" type="text" value="@selectedOption" /> 1087 } 1088 1089 <select data-size="8" class="composed pull-right"> 1090 @foreach (LoopItem option in facets.Where(x => x.GetString("FacetOption.Value") != "0")) 1091 { 1092 string optionFacetName = option.GetString("Facet.Name"); 1093 string optionFacetFilter = optionFacetName.Substring(optionFacetName.LastIndexOf('_') + 1,optionFacetName.Length - optionFacetName.LastIndexOf('_') - 1); 1094 string optionFacetFilterLabel = composedLabels.ContainsKey(optionFacetFilter.ToLower()) ? composedLabels[optionFacetFilter.ToLower()] : optionFacetFilter; 1095 <option selected="@(selectedFilter == optionFacetFilter)" value="@optionFacetFilter">@optionFacetFilterLabel</option> 1096 } 1097 </select> 1098 </fieldset> 1099 } 1100 @SnippetStart("jsOnLoad") 1101 @:onLoadFilters() 1102 @SnippetEnd("jsOnLoad") 1103 } 1104 if (!haveKits) 1105 { 1106 string isHidden = "", ids = "("; 1107 foreach (var t in productsList) 1108 { 1109 ids += "'" + t.GetString("Ecom:Product.ID") + "'" + ","; 1110 } 1111 ids = ids.Remove(ids.Length - 1, 1) + ")"; 1112 1113 @* Show the three types of dimension type available *@ 1114 <div class="@isHidden @classDiv noPadding products" data-kits="@haveKits"> 1115 <div class="col-xs-12 noPaddingRight"> 1116 1117 @if(productsList.Any()) { 1118 List<LoopItem> inchProducts = productsList.Where(x => x.GetString("Ecom:Product:Field.DimensionType").Equals("Inch")).ToList(), 1119 metricProducts = productsList.Where(x => x.GetString("Ecom:Product:Field.DimensionType").Equals("Metric")).ToList(), 1120 noTypeProducts = productsList.Where(x => !x.GetString("Ecom:Product:Field.DimensionType").Equals("Metric") && !x.GetString("Ecom:Product:Field.DimensionType").Equals("Inch")).ToList(), 1121 noDimensionProducts = productsList.Where(x => x.GetString("Ecom:Product:Field.Dimensions.Value").Equals("")).ToList(); 1122 1123 if(noDimensionProducts.Count() == productsList.Count()) { 1124 <div class="blueBackgroundStripes col-xs-12"> 1125 <h2 class="col-xs-3 noPaddingLeft">@String.Format("{0} to {1} of {2}", startValue, toValue, total)</h2> 1126 @RenderPagination() 1127 </div> 1128 @CreateTable(noDimensionProducts, make, ids, false,first,"",true) 1129 <div class="blueBackgroundStripes col-xs-12"> 1130 @RenderPagination() 1131 </div> 1132 } 1133 else { 1134 <div class="blueBackgroundStripes col-xs-12"> 1135 <h2 class="col-xs-3 noPaddingLeft">@String.Format("{0} to {1} of {2}", startValue , toValue , total)</h2> 1136 @RenderPagination() 1137 </div> 1138 if(inchProducts.Any()) { 1139 @CreateTable(inchProducts, make, ids,false,first,Translate("inch","Inch"),false) 1140 first = false; 1141 } 1142 if(metricProducts.Any()) { 1143 @CreateTable(metricProducts, make, ids,true,first,Translate("metric","Metric"),false) 1144 } 1145 if(noTypeProducts.Any()) { 1146 @CreateTable(noTypeProducts, make, ids,false,first,"",false) 1147 } 1148 <div class="blueBackgroundStripes col-xs-12"> 1149 @RenderPagination() 1150 </div> 1151 } 1152 } 1153 1154 </div> 1155 </div> 1156 } 1157 else { 1158 List<LoopItem> facetOptions = getFacetOptions("ItemMakes"); 1159 1160 if(String.IsNullOrEmpty(make) && facetOptions != null && facetOptions.Any()) { 1161 <div class="col-xs-12 noPadding" id="makes"> 1162 <h2 id="productListTitle">@makesTitle</h2> 1163 @RenderMakes(facetOptions,null,false) 1164 </div> 1165 } 1166 else if(!String.IsNullOrEmpty(make) && String.IsNullOrEmpty(model) && String.IsNullOrEmpty(feature)) 1167 { 1168 <h2 id="productListTitle">@makesTitle</h2> 1169 @RenderMakesOptions(products,make, groupID) 1170 } 1171 else 1172 { 1173 <div id="results-list" class="@classDiv"> 1174 @if(GetBoolean("Ecom:Group:Field.Multipack")){ 1175 <div class="blueBackgroundStripes col-xs-12"> 1176 <h2 class="col-xs-3 noPaddingLeft">@String.Format("{0} to {1} of {2}", startValue , toValue , total)</h2> 1177 @RenderPagination() 1178 </div> 1179 } 1180 <div class="col-xs-12 noPaddingRight"> 1181 @RenderProductsListView(products) 1182 </div> 1183 @if(GetBoolean("Ecom:Group:Field.Multipack")){ 1184 <div class="blueBackgroundStripes col-xs-12"> 1185 <h2 class="col-xs-3 noPaddingLeft">@String.Format("{0} to {1} of {2}", startValue , toValue , total)</h2> 1186 @RenderPagination() 1187 </div> 1188 } 1189 </div> 1190 } 1191 } 1192 } 1193 else 1194 { 1195 <h2>No Products Available</h2> 1196 } 1197 1198 @helper RenderMakesOptions(List<LoopItem> products,string make, string groupID) { 1199 DataSet productsDataSet = Dynamicweb.Data.Database.CreateDataSet(String.Format("SELECT ProductID FROM EcomProducts WHERE ProductType = '{0}' AND ProductID IN(SELECT DISTINCT GroupProductRelationProductID from EcomGroupProductRelation WHERE GroupProductRelationGroupID IN (SELECT GroupRelationsGroupID FROM EcomGroupRelations WHERE GroupRelationsGroupID = '{1}' OR GroupRelationsParentID = '{1}' OR GroupRelationsParentID IN(SELECT GroupRelationsGroupID FROM EcomGroupRelations WHERE GroupRelationsParentID = '{1}')))", (Dynamicweb.Context.Current.Request["ProductType"] ?? "").ToString(), groupID)); 1200 string prodIds = ""; 1201 1202 if (productsDataSet.Tables.Count > 0) { 1203 foreach (DataRow r in productsDataSet.Tables[0].Rows) { 1204 prodIds += String.Format("'{0}',", r["ProductID"].ToString()); 1205 } 1206 if (prodIds.Length != 0) 1207 { 1208 prodIds = "(" + prodIds.Remove(prodIds.Length - 1, 1) + ")"; 1209 } 1210 } 1211 1212 @CreateTable(products, make, prodIds, false,false,"",false) 1213 } 1214 1215 @helper CreateTable(List<LoopItem> products, string makes,string ids,bool isMetric,bool isFirst,string title,bool hideDimension) { 1216 var page = Pageview.Area.Item; 1217 System.Data.DataSet result = null; 1218 if(!String.IsNullOrEmpty(makes) && !String.IsNullOrEmpty(ids)) { 1219 string getModelsAndFeatures = String.Format("SELECT DISTINCT m_mf.Model, m_mf.Feature, f.Product_ID FROM ItemType_Make_ModelAnd_Features m_mf inner join ItemType_Fitments f on CHARINDEX(m_mf.id, f.Fits) > 0 and f.Product_ID IN {0} where m_mf.Make = '{1}'",ids,makes.Replace("_"," ").Replace(",","|").Replace("*","''")); 1220 result = Dynamicweb.Data.Database.CreateDataSet(getModelsAndFeatures); 1221 } 1222 1223 var dimensionType = GetString("Ecom:Group:Field.DimensionType.Value.Clean"); 1224 var sortByField = string.Empty; 1225 1226 switch (dimensionType) 1227 { 1228 case "Diameter": 1229 sortByField = "ProductCategory_Balls_Diameter"; 1230 break; 1231 case "Shaft Diameter": 1232 sortByField = "ProductCategory_MountedUB_Shaft_Diameter"; 1233 break; 1234 default: 1235 sortByField = "CustomField_Id"; 1236 break; 1237 } 1238 1239 string classDiv = !String.IsNullOrEmpty(makes) ? "noPadding" : "noPadding noPaddingRight", 1240 urlBrowse = page["BrowseAll"].ToString(), 1241 parentID = (Dynamicweb.Context.Current.Request["parentID"] ?? "").ToString(), 1242 parameter = !String.IsNullOrEmpty(parentID) ? "parentID=" + parentID : "GroupID=" + GetString("Ecom:Group.ID"), 1243 prodTypeParameter = (Dynamicweb.Context.Current.Request["ProductType"] ?? "").ToString(), 1244 currentPage = "/Default.aspx?ID=" + Pageview.Page.ID + "&" + parameter + String.Format("{0}&{1}", !String.IsNullOrWhiteSpace(prodTypeParameter) ? String.Format("&ProductType={0}", prodTypeParameter) : "", "searchSize=true"), 1245 sortby = (Dynamicweb.Context.Current.Request["sortby"] ?? "").ToString(), 1246 sortorder = (Dynamicweb.Context.Current.Request["sortorder"] ?? "").ToString(), 1247 sortByDimension = String.Format("{0}&sortby="+ sortByField +"&sortorder={1}", currentPage, sortby == sortByField && sortorder == "desc" ? "asc" : "desc"), 1248 sortByPart = String.Format("{0}&sortby=Name&sortorder={1}", currentPage, sortby == "Name" && sortorder == "desc" ? "asc" : "desc"), 1249 sortByPrice = String.Format("{0}&sortby=Price&sortorder={1}", currentPage, sortby == "Price" && sortorder == "desc" ? "asc" : "desc"), 1250 inquirePage = (page["InquireAboutAvailability"] ?? "").ToString(), 1251 groupID = GetString("Ecom:Group.ID"), 1252 browseMetric = String.Format("{0}&parentID={1}&DimensionType=metric",urlBrowse,groupID), 1253 browseInch = String.Format("{0}&parentID={1}&DimensionType=inch",urlBrowse,groupID), 1254 prodTitle = !String.IsNullOrEmpty(makes) ? Translate("modelFeature","Model / Feature"): Translate("part#", "Part #"), 1255 nameColumnWidth = hideDimension ? "7" : "4"; 1256 var miniCartPage = (Pageview.Area.Item["MiniCart"] ?? "").ToString(); 1257 1258 <div class="col-xs-12 noPadding newType"> 1259 <div class="col-xs-12 @classDiv"> 1260 @if(!haveKits){ 1261 <div id="productListTable"> 1262 <p>@title</p> 1263 <div class="table-list-header"> 1264 <div class="row hidden-xs"> 1265 @if(!hideDimension) 1266 { 1267 var dimensionHeader = !string.IsNullOrEmpty(GetString("Ecom:Group:Field.DimensionType.Value.Clean")) ? Translate(GetString("Ecom:Group:Field.DimensionType.Value.Clean")) : Translate("dimension", "Dimension"); 1268 <div class="col-xs-12 col-sm-3 noPaddingRight">@dimensionHeader <a href="@sortByDimension"><i class="fa fa-sort"></i></a></div> 1269 } 1270 <div class="col-xs-12 col-sm-@(nameColumnWidth)">@prodTitle <a href="@sortByPart"><i class="fa fa-sort"></i></a></div> 1271 <div class="col-xs-12 col-sm-1 text-right noPadding">@Translate("price", "Price") <a href="@sortByPrice"><i class="fa fa-sort"></i></a></div> 1272 <div class="col-xs-12 col-sm-4 "> </div> 1273 </div> 1274 </div> 1275 </div> 1276 } 1277 <ul id="productsHolder" class="productList col-xs-12 list-view noPadding"> 1278 @if(String.IsNullOrEmpty(makes)) { 1279 foreach (var product in products) 1280 { 1281 string variant_ID = product.GetString("Ecom:Product.VariantID"), 1282 str_productName = product.GetString("Ecom:Product.Name"), 1283 str_productID = product.GetString("Ecom:Product.ID"), 1284 str_productLink = product.GetString("Ecom:Product.Link.Clean"), 1285 str_productDimensions = product.GetString("Ecom:Product:Field.Dimensions.Value").Replace("Metric","").Replace("Inch","").Replace("es","").Replace("Millimeters",""), 1286 str_productInnerDimension = product.GetString("Ecom:Product:Field.ID.Value"), 1287 str_productOuterDimension = product.GetString("Ecom:Product:Field.OD.Value"), 1288 str_productWidth = product.GetString("Ecom:Product:Field.Width.Value"), 1289 price = product.GetString("Ecom:Product.Price"), 1290 addToCartUrl = "/Default.aspx?productid=" + str_productID + "&cartcmd=add"; 1291 str_productDimensions = RenderDimensions(str_productDimensions).ToString(); 1292 @RenderProductRow(str_productDimensions,str_productName,price,product.GetInteger("Ecom:Product.Stock"), 1293 miniCartPage,str_productID,str_productLink,variant_ID,inquirePage,groupID,parentID,hideDimension, product) 1294 1295 1296 1297 } 1298 } 1299 else { 1300 if (result.Tables.Count > 0 && result.Tables[0].Rows.Count > 0) { 1301 Dictionary<string,string> relation = new Dictionary<string,string>(); 1302 foreach (DataRow info in result.Tables[0].Rows) { 1303 string prodID = info["Product_Id"].ToString(), 1304 str_productName = info["Model"].ToString() + "|" + info["Feature"].ToString(); 1305 1306 if (!relation.ContainsKey(str_productName)) { 1307 relation.Add(str_productName,str_productName); 1308 } 1309 1310 var product = products.Where( x => x.GetString("Ecom:Product.ID").Equals(prodID)).FirstOrDefault(); 1311 if(product == null){ 1312 continue; 1313 } 1314 1315 string str_productDimensions = product.GetString("Ecom:Product:Field.Dimensions.Value").Replace("Metric","").Replace("Inch","").Replace("es","").Replace("Millimeters",""), 1316 variant_ID = product.GetString("Ecom:Product.VariantID"), 1317 str_productLink = product.GetString("Ecom:Product.Link.Clean"), 1318 price = product.GetString("Ecom:Product.Price"), 1319 addToCartUrl = "/Default.aspx?productid=" + prodID + "&cartcmd=add"; 1320 str_productDimensions = RenderDimensions(str_productDimensions).ToString(); 1321 1322 if(!haveKits) { 1323 @RenderProductRow(str_productDimensions,str_productName,price,product.GetInteger("Ecom:Product.Stock"), 1324 miniCartPage ,prodID,str_productLink,variant_ID,inquirePage,groupID,parentID,hideDimension, product) 1325 } 1326 } 1327 @RenderMakes(null,relation,false) 1328 } 1329 } 1330 1331 1332 </ul> 1333 </div> 1334 </div> 1335 } 1336 1337 @helper RenderDimension(string dimension, LoopItem product) 1338 { 1339 var dimensionType = GetString("Ecom:Group:Field.DimensionType.Value.Clean"); 1340 1341 switch (dimensionType) 1342 { 1343 case "Diameter": 1344 @RenderDimensionField(dimensionType, product) 1345 break; 1346 case "Shaft Diameter": 1347 @RenderDimensionField(dimensionType, product) 1348 break; 1349 default: 1350 @dimension 1351 break; 1352 } 1353 } 1354 1355 @helper RenderDimensionField(string dimensionType, LoopItem product) 1356 { 1357 foreach (var category in product.GetLoop("ProductCategories")) 1358 { 1359 foreach (var field in category.GetLoop("ProductCategoryFields")) 1360 { 1361 var key = field.GetString("Ecom:Product.CategoryField.Label"); 1362 var value = field.GetString("Ecom:Product.CategoryField.Value"); 1363 if(key.ToLower().Equals(dimensionType.ToLower())) 1364 { 1365 @value; 1366 } 1367 } 1368 } 1369 } 1370 1371 @helper RenderProductRow(string dimension, string name,string price,int stock, string currentPage, string productId,string prodLink, 1372 string variant,string inquirePage,string groupID,string parentID, bool hideDimension, LoopItem product) { 1373 1374 string addToCartClass = stock > 0 ? "" : "noStockAvailable"; 1375 string nameColumnWidth = hideDimension ? "7" : "4"; 1376 <li class="row"> 1377 @if(!hideDimension) { 1378 <div class="col-xs-11 col-sm-3"> 1379 <div class="dimensions">@RenderDimension(dimension, product)</div> 1380 </div> 1381 } 1382 <div class="col-xs-12 col-sm-@(nameColumnWidth)"> 1383 <h2><a href="@prodLink">@name</a></h2> 1384 </div> 1385 <div class="col-xs-12 col-sm-1 noPadding"> 1386 <div class="pull-right" itemprop="price">@price</div> 1387 </div> 1388 <div class="col-xs-12 col-sm-4 addForm"> 1389 <div class="pull-right @addToCartClass"> 1390 @if(stock > 0){ 1391 <form name="addToCart" class="add-to-cart form-fields" action="@currentPage" method="post"> 1392 <input type="hidden" name="cartcmd" value="add" /> 1393 <input type="hidden" name="productID" value="@productId" /> 1394 <input type="hidden" name="variantID" value="@variant" @((String.IsNullOrEmpty(variant)) ? "disabled='disabled'" : "") /> 1395 <input type="hidden" name="redirect" value="false" /> 1396 <span class="qty-label">Qty</span> 1397 <input class="quantity" name="Quantity" type="number" value="1" maxlength="4" min="1" /> 1398 <a class='btn-blue generalButton btn-action pull-right addToCartSubmit addToCartTracking'> 1399 @Translate("addToCart", "Add to Cart") @*CUSTOM CODE - removed icon*@ 1400 </a> 1401 1402 </form> 1403 } 1404 else 1405 { 1406 <a class="btn-softBlue pull-right inquireAboutAvailability" href="/Default.aspx?ID=@inquirePage&prodID=@productId">@Translate("Inquire") <i class="fa fa-comment fa-2x"></i></a> 1407 } 1408 1409 </div> 1410 </div> 1411 </li> 1412 } 1413 1414 @SnippetStart("jsOnLoad") 1415 onLoadGenericProductList(); 1416 @SnippetEnd("jsOnLoad") 1417 @helper RenderPagination() { 1418 if(GetInteger("Ecom:ProductList.TotalPages") > 1) { 1419 string prevPage = GetString("Ecom:ProductList.PrevPage.Clean"), 1420 str_nextPage = GetString("Ecom:ProductList.NextPage.Clean"), 1421 prevClass = String.IsNullOrEmpty(str_nextPage) ? "pull-right" : ""; 1422 1423 prevPage += !String.IsNullOrEmpty(prevPage) && !prevPage.Contains("searchSize=") ? "&searchSize=true" : ""; 1424 str_nextPage += !String.IsNullOrEmpty(str_nextPage) && !str_nextPage.Contains("searchSize=") ? "&searchSize=true" : ""; 1425 1426 <ul class="pull-right col-sm-4 col-xs-9 paging"> 1427 @if(!String.IsNullOrEmpty(prevPage)) { 1428 <li class="col-xs-6 col-sm-6 col-sm-offset-2 col-md-offset-0 noPadding @prevClass"> 1429 <a href="@prevPage"><< @Translate("Previous","Previous")</a> 1430 </li> 1431 } 1432 @if(!String.IsNullOrEmpty(str_nextPage)) { 1433 <li class="col-xs-6 col-sm-3 noPadding pull-right"> 1434 <a href="@str_nextPage">@Translate("Next","Next") >></a> 1435 </li> 1436 } 1437 </ul> 1438 } 1439 } 1440 1441 @SnippetStart("ProductType") 1442 @if(facetGroups != null && facetGroups.Any()){ 1443 bool isMakesAvailable = false; 1444 bool isSizesAvailable = false; 1445 var prodTypeFacet = facetGroups.FirstOrDefault().GetLoop("Facets").Where(f => f.GetString("Facet.Name").Equals("ProductType")).FirstOrDefault(); 1446 1447 if(prodTypeFacet != null){ 1448 var prodTypeFacetOptions = prodTypeFacet.GetLoop("FacetOptions"); 1449 isMakesAvailable = prodTypeFacetOptions.Any(x => x.GetString("FacetOption.Value").Equals("2")); 1450 isSizesAvailable = prodTypeFacetOptions.Any(x => x.GetString("FacetOption.Value").Equals("0")); 1451 if(prodTypeFacetOptions.Any()) { 1452 bool isMultipack = GetBoolean("Ecom:Group:Field.Multipack"); 1453 string modelText = isMultipack ? Translate("searchMultipacks", "Search by Multipacks") : Translate("searchMakesModels", "Search by Manufacturer/Model"); 1454 string sizeText = isMultipack ? Translate("searchSingleBearings", "Single Bearings") : Translate("searchSize", "Search by Size"); 1455 1456 if(isMakesAvailable){ 1457 <li data-id="makesSearch" class="makesSearch @isMakeActives"><a href="@searchByMakesModelsLink" onclick="ProductBorderColorBlue()">@modelText</a></li> 1458 } 1459 if(isSizesAvailable){ 1460 <li data-id="sizeSearch" class="sizeSearch @isSizeActives"><a href="@searchBySizesLink" onclick="ProductBorderColorGreen()">@sizeText</a></li> 1461 } 1462 } 1463 } 1464 1465 if(String.IsNullOrEmpty(prodTypes) && !groupID.Contains("L1")) { 1466 string str_redirect = isMakesAvailable ? Dynamicweb.Context.Current.Request.Url.AbsoluteUri + "&ProductType=2" : Dynamicweb.Context.Current.Request.Url.AbsoluteUri + "&ProductType=0"; 1467 Dynamicweb.Context.Current.Response.Redirect(str_redirect); 1468 } 1469 } 1470 @SnippetEnd("ProductType") 1471 1472 @using System 1473 @using Dynamicweb.Environment; 1474 @helper RenderProductsListView(List<LoopItem> productsListView) 1475 { 1476 string str_imagesFolder = "/Files/Files/BocaBearing/Products/images/"; 1477 1478 <ul id="productsHolder" class="productList list-view"> 1479 @foreach (LoopItem product in productsListView){ 1480 string str_imagePattern = str_imagesFolder + product.GetString("Ecom:Product.Number") + ".jpg"; 1481 string str_image = !string.IsNullOrEmpty(product.GetString("Ecom:Product.ImageSmall.Default.Clean")) ? product.GetString("Ecom:Product.ImageSmall.Default.Clean") : !string.IsNullOrEmpty(product.GetString("Ecom:Product.ImageMedium.Default.Clean")) ? product.GetString("Ecom:Product.ImageMedium.Default.Clean") : !string.IsNullOrEmpty(product.GetString("Ecom:Product.ImageLarge.Default.Clean")) ? product.GetString("Ecom:Product.ImageLarge.Default.Clean") : str_imagePattern; 1482 str_image = str_image.Replace("/Files/files/files/", "/Files/files/"); 1483 1484 string groupId = product.GetString("Ecom:Product.PrimaryGroupID"); 1485 string str_productName = product.GetString("Ecom:Product.Name"); 1486 string str_productID = product.GetString("Ecom:Product.ID"); 1487 string str_productVariantID = product.GetString("Ecom:Product.VariantID"); 1488 string str_link = ""; 1489 bool bol_userLogged = Dynamicweb.Security.UserManagement.User.IsExtranetUserLoggedIn(); 1490 string itemMakes = (Dynamicweb.Context.Current.Request["ItemMakes"] ?? "").ToString(), 1491 ItemModels = (Dynamicweb.Context.Current.Request["ItemModels"] ?? "").ToString(), 1492 ItemFeatures = (Dynamicweb.Context.Current.Request["ItemFeatures"] ?? "").ToString(); 1493 string dimensions = product.GetString("Ecom:Product:Field.Dimensions.Value"); 1494 str_link = "/Default.aspx?ID=" + Pageview.Area.Item["ProductPage"].ToString() + "&productid=" + str_productID; 1495 str_link += !String.IsNullOrWhiteSpace(itemMakes) ? String.Format("&make={0}", itemMakes.Replace("_", " ")) : ""; 1496 str_link += !String.IsNullOrWhiteSpace(ItemModels) ? String.Format("&model={0}", ItemModels.Replace("_", " ")) : ""; 1497 str_link += !String.IsNullOrWhiteSpace(ItemFeatures) ? String.Format("&feature={0}", ItemFeatures.Replace("_", " ")) : ""; 1498 1499 <li class="row"> 1500 <h2 class="product-long-name col-xs-12"><a itemprop="name" href="@str_link">@product.GetString("Ecom:Product.Name")</a></h2> 1501 <div class="col-xs-11 col-sm-2"> 1502 <figure class="text-center"> 1503 <a href="@str_link"> 1504 <img src="@GetImage(str_image, 0, 116, 0, 0, 0, 0, "jpg")" alt="@str_productName" title="@str_productName" class="img-responsive" /> 1505 </a> 1506 </figure> 1507 1508 </div> 1509 <div class="col-xs-12 col-sm-4 noPaddingLeft productInfo"> 1510 <p> 1511 <strong>@Translate("sku","SKU"):</strong> @str_productName 1512 </p> 1513 @if(!String.IsNullOrEmpty(dimensions)) { 1514 double inner = product.GetDouble("Ecom:Product:Field.ID.Value.Raw"); 1515 double outer = product.GetDouble("Ecom:Product:Field.OD.Value.Raw"); 1516 double width = product.GetDouble("Ecom:Product:Field.Width.Value.Raw"); 1517 string dimension = product.GetString("Ecom:Product:Field.Dimensions.Value").Replace("Metric","").Replace("Inch","").Replace("es","").Replace("Millimeters",""); 1518 1519 <p>@Translate("dimension", "Dimension"): @RenderDimensions(dimension)</p> 1520 } 1521 1522 <p> 1523 @if (str_productName.StartsWith("#")){ 1524 <div class="module line-clamp">@product.GetString("Ecom:Product.LongDescription")</div> 1525 } 1526 <a class="more-info" href="@str_link">@Translate("moreInfo","More Info")</a> 1527 </p> 1528 </div> 1529 @RenderPriceContainer(product,Pageview.Area.Item) 1530 @CheckStock(Pageview.Area.Item,str_productID,str_productVariantID,product) 1531 1532 </li> 1533 <hr/> 1534 } 1535 </ul> 1536 } 1537