public ActionResult _GetProductByCategoryAndFilters(int shopID, int?categoryID, int[] filters, string viewIn = "gallery", int skip = 0, int take = 20, string keywords = null, bool showFirstCategory = false, bool isBestSelling = false, string productName = "", bool refreshFilters = true, bool isForSpider = false) { List <SpecificationOptionModel> specifications = null; IEnumerable <ProductOverviewModel> data; var profiler = MiniProfiler.Current; using (profiler.Step("Step Controller _ByCategoryAndFilters")) { if (string.IsNullOrEmpty(productName)) { if (showFirstCategory) { //var sc = LS.Get<ShopCategory>().OrderBy(x => x.DisplayOrder).Where(x => x.Published).FirstOrDefault(); //var category1 = LS.Get<Category>().ToList(); var sc = LS.Get <ShopCategoryMenu>().FirstOrDefault(x => x.ShopID == shopID && x.Published == true && x.Level == 0); if (sc != null) { categoryID = sc.CategoryID; } else { var shopCatMap = LS.Get <ShopCategory>().Where(x => x.Published); var shc = shopCatMap.OrderBy(x => x.DisplayOrder).FirstOrDefault(); if (shc != null) { categoryID = shc.CategoryID; } } } bool FeautureTop = false; if (!categoryID.HasValue && (filters == null || filters.Length == 0) && string.IsNullOrEmpty(keywords) && !isBestSelling ) { FeautureTop = true; } data = LS.SearchProducts( shopID: shopID, options: out specifications, page: isForSpider ? 1 : (skip / take) + 1, limit: isForSpider ? -1 : take, categoryID: categoryID, filters: filters, loadSpecifications: skip == 0, keywords: keywords, isBestSelling: isBestSelling, featuredTop: FeautureTop, showDiscounts: true); foreach (var d in data) { //d.ProductNoteText = ShoppingService.GetUserNoteForProduct(d.ProductID, LS.CurrentUser.ID); } } else { data = LS.SearchProducts(shopID, out specifications, (skip / take) + 1, take // , categoryID: categoryID // , filters: filters //, loadSpecifications: skip == 0, , productName: productName //, isBestSelling: isBestSelling // , featuredTop: FeautureTop , showDiscounts: true ); } ViewBag.LastProductNum = skip + take; //data.Count(); ViewBag.Specifications = specifications; ViewBag.RefreshFilters = refreshFilters; ViewBag.CategoryID = categoryID; if (categoryID.HasValue) { var cat = LS.Get <Category>().FirstOrDefault(x => x.ID == categoryID.Value); if (cat != null) { ViewBag.Category = cat; } } if (!string.IsNullOrEmpty(productName) && data.Count() == 0 || !string.IsNullOrEmpty(keywords) && data.Count() == 0) { return(Json(new { status = "productNotFound", localizationMessage = RP.T("ShopController.SearchMessage.ProductNotFound").ToString(), localizationTextComponent = RP.Text("ShopController.SearchMessage.ProductNotFoundComponent").ToString() }, JsonRequestBehavior.AllowGet)); } } if (data.Count() == 0) { return(Content(string.Empty)); } var shop = LS.Get <Shop>().FirstOrDefault(x => x.ID == shopID); if (shop != null) { if (!string.IsNullOrEmpty(shop.Theme)) { this.HttpContext.Items["ShopTheme"] = shop.Theme; } ViewBag.Shop = shop; } switch (viewIn) { case "gallery": return(PartialView("_ProductsGallery", data)); case "table": return(PartialView("_ProductsTable", data)); case "tableItemPartial": return(PartialView("_ProductTableItem", data)); } return(Content(string.Empty)); }