public ActionResult ShowByGroupSlug(string slug, int?p) { int limit = 12; try { limit = int.Parse(ThemesSetting.getValue("ProductPageLimit").ToString()); } catch { } var group = _productSevice.GetProductClassBySlug(slug); if (group == null) { return(RedirectToAction("Index")); } var findter = _productSevice.GetFindterProduct(); findter.AddGroupId(group.Id); var count = findter.GetCount(); var Paging = CalcPaging(limit, p, count); var model = new CategoryProductListViewModel { Group = group, Paging = Paging, ListProduct = findter.GetList(limit, Paging.Page) }; return(View(model)); }
public ActionResult ShowBySlugProduct(string Slug, int?p, List <Guid> group) { var cat = _categoryService.GetBySlug(Slug); if (cat == null) { return(Redirect("/" + SiteConstants.Instance.ProductUrlIdentifier)); } var cats = _categoryService.GetTreeCategories(cat); var ProductFindter = _productSevice.GetFindterProduct(); if (group != null) { ProductFindter.AddGroupId(group); } else { group = new List <Guid>(); } if (cats != null) { ProductFindter.AddCat(cats); } var groupclass = _productSevice.GetClassByProducts(cats); var attr = _productSevice.GetAttributeByClass(groupclass, true); List <CategoryProductFindterViewModel> Attributes = new List <CategoryProductFindterViewModel>(); foreach (var it in attr) { var cl = new CategoryProductFindterViewModel { Name = it.LangName, Title = string.Concat("Product.Attribute.", it.LangName), Options = new List <CategoryProductFindterOption>() }; if (it.ValueType == 2) { if (it.ValueOption.IsNullEmpty()) { continue; } dynamic json = JsonConvert.DeserializeObject(it.ValueOption); if (json == null) { continue; } foreach (var itt in json) { var pit = new CategoryProductFindterOption { Value = itt, Text = itt, }; if (Request[string.Concat(cl.Name, ".", pit.Value)] == "1") { pit.Check = true; ProductFindter.SetAttributeEquas(it.Id, (string)itt); } cl.Options.Add(pit); } } Attributes.Add(cl); } int limit = 10; try { limit = int.Parse(ThemesSetting.getValue("ProductPageLimit").ToString()); } catch { } var count = ProductFindter.GetCount(); var Paging = CalcPaging(limit, p, count); var model = new CategoryProductListViewModel { Cat = cat, Paging = Paging, ListProduct = ProductFindter.GetList(limit, Paging.Page), GroupProducts = groupclass, GroupSelect = group, Attributes = Attributes }; return(View(model)); }