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