public ActionResult ProductsByTag(int productTagId, CatalogPagingFilteringModel command) { var productTag = _productTagService.GetProductTagById(productTagId); if (productTag == null) return HttpNotFound(); if (command.PageNumber <= 0) command.PageNumber = 1; var model = new ProductsByTagModel() { Id = productTag.Id, TagName = productTag.GetLocalized(y => y.Name) }; if (command.OrderBy == (int)ProductSortingEnum.Initial) { command.OrderBy = (int)_catalogSettings.DefaultSortOrder; } _helper.PreparePagingFilteringModel(model.PagingFilteringContext, command, new PageSizeContext { AllowCustomersToSelectPageSize = _catalogSettings.ProductsByTagAllowCustomersToSelectPageSize, PageSize = _catalogSettings.ProductsByTagPageSize, PageSizeOptions = _catalogSettings.ProductsByTagPageSizeOptions.IsEmpty() ? _catalogSettings.DefaultPageSizeOptions : _catalogSettings.ProductsByTagPageSizeOptions }); //products var ctx = new ProductSearchContext(); ctx.ProductTagId = productTag.Id; ctx.LanguageId = _services.WorkContext.WorkingLanguage.Id; ctx.OrderBy = (ProductSortingEnum)command.OrderBy; ctx.PageIndex = command.PageNumber - 1; ctx.PageSize = command.PageSize; ctx.StoreId = _services.StoreContext.CurrentStoreIdIfMultiStoreMode; ctx.VisibleIndividuallyOnly = true; var products = _productService.SearchProducts(ctx); model.Products = _helper.PrepareProductOverviewModels( products, prepareColorAttributes: true, prepareManufacturers: command.ViewMode.IsCaseInsensitiveEqual("list")).ToList(); model.PagingFilteringContext.LoadPagedList(products); //model.PagingFilteringContext.ViewMode = viewMode; return View(model); }
public ActionResult ProductsByTag(int productTagId, CatalogPagingFilteringModel command) { var productTag = _productTagService.GetProductTagById(productTagId); if (productTag == null) return RedirectToRoute("HomePage"); if (command.PageNumber <= 0) command.PageNumber = 1; var model = new ProductsByTagModel() { Id = productTag.Id, TagName = productTag.GetLocalized(y => y.Name) }; // codehint: sm-edit (replaced) PreparePagingFilteringModel(model.PagingFilteringContext, command, new PageSizeContext { AllowCustomersToSelectPageSize = _catalogSettings.ProductsByTagAllowCustomersToSelectPageSize, PageSize = _catalogSettings.ProductsByTagPageSize, PageSizeOptions = _catalogSettings.ProductsByTagPageSizeOptions.IsEmpty() ? _catalogSettings.DefaultPageSizeOptions : _catalogSettings.ProductsByTagPageSizeOptions }); //products var ctx = new ProductSearchContext(); ctx.ProductTagId = productTag.Id; ctx.LanguageId = _workContext.WorkingLanguage.Id; ctx.OrderBy = (ProductSortingEnum)command.OrderBy; ctx.PageIndex = command.PageNumber - 1; ctx.PageSize = command.PageSize; ctx.StoreId = _storeContext.CurrentStoreIdIfMultiStoreMode; ctx.VisibleIndividuallyOnly = true; var products = _productService.SearchProducts(ctx); model.Products = PrepareProductOverviewModels(products, prepareColorAttributes: true).ToList(); model.PagingFilteringContext.LoadPagedList(products); //model.PagingFilteringContext.ViewMode = viewMode; // codehint: sm-delete return View(model); }