public SearchModel() { PagingFilteringContext = new SearchPagingFilteringModel(); Products = new List<ProductOverviewModel>(); this.AvailableCategories = new List<SelectListItem>(); this.AvailableManufacturers = new List<SelectListItem>(); }
public SearchModel() { PagingFilteringContext = new SearchPagingFilteringModel(); Products = new List <ProductOverviewModel>(); this.AvailableCategories = new List <SelectListItem>(); this.AvailableManufacturers = new List <SelectListItem>(); }
public SearchModel() { PagingFilteringContext = new SearchPagingFilteringModel(); Products = new List <ProductModel>(); this.AvailableCategories = new List <SelectListItem>(); this.AvailablePublishers = new List <SelectListItem>(); }
public ActionResult Search(SearchModel model, SearchPagingFilteringModel command) { if (model == null) { model = new SearchModel(); } if (command.PageSize <= 0) { command.PageSize = _catalogSettings.SearchPageProductsPerPage; } if (command.PageNumber <= 0) { command.PageNumber = 1; } if (model.Q == null) { model.Q = ""; } model.Q = model.Q.Trim(); IPagedList <Product> products = new PagedList <Product>(new List <Product>(), 0, 1); // only search if query string search keyword is set (used to avoid searching or displaying search term min length error message on /search page load) if (Request.Params["Q"] != null) { if (model.Q.Length < _catalogSettings.ProductSearchTermMinimumLength) { model.Warning = string.Format(_localizationService.GetResource("Search.SearchTermMinimumLengthIsNCharacters"), _catalogSettings.ProductSearchTermMinimumLength); } else { //products products = _productService.SearchProducts( storeId: _storeContext.CurrentStore.Id, visibleIndividuallyOnly: true, keywords: model.Q, languageId: _workContext.WorkingLanguage.Id, pageIndex: command.PageNumber - 1, pageSize: command.PageSize); model.Products = PrepareProductOverviewModels(products).ToList(); model.NoResults = !model.Products.Any(); } } model.PagingFilteringContext.LoadPagedList(products); return(View("Nop.Plugin.Misc.FacebookShop.Views.MiscFacebookShop.Search", model)); }
public SearchModel() { PagingFilteringContext = new SearchPagingFilteringModel(); Products = new List<ProductOverviewModel>(); }
public ActionResult Search(SearchModel model, SearchPagingFilteringModel command) { if (model == null) model = new SearchModel(); if (command.PageSize <= 0) command.PageSize = _catalogSettings.SearchPageProductsPerPage; if (command.PageNumber <= 0) command.PageNumber = 1; if (model.Q == null) model.Q = ""; model.Q = model.Q.Trim(); IPagedList<Product> products = new PagedList<Product>(new List<Product>(), 0, 1); // only search if query string search keyword is set (used to avoid searching or displaying search term min length error message on /search page load) if (Request.Params["Q"] != null) { if (model.Q.Length < _catalogSettings.ProductSearchTermMinimumLength) { model.Warning = string.Format(_localizationService.GetResource("Search.SearchTermMinimumLengthIsNCharacters"), _catalogSettings.ProductSearchTermMinimumLength); } else { //products products = _productService.SearchProducts( storeId: _storeContext.CurrentStore.Id, visibleIndividuallyOnly: true, keywords: model.Q, languageId: _workContext.WorkingLanguage.Id, pageIndex: command.PageNumber - 1, pageSize: command.PageSize); model.Products = PrepareProductOverviewModels(products).ToList(); model.NoResults = !model.Products.Any(); } } model.PagingFilteringContext.LoadPagedList(products); return View("Nop.Plugin.Misc.FacebookShop.Views.MiscFacebookShop.Search", model); }
public ActionResult Search(SearchModel model, SearchPagingFilteringModel command) { if (model == null) model = new SearchModel(); //'Continue shopping' URL _customerService.SaveCustomerAttribute(_workContext.CurrentCustomer, SystemCustomerAttributeNames.LastContinueShoppingPage, _webHelper.GetThisPageUrl(false)); if (command.PageSize <= 0) command.PageSize = _catalogSettings.SearchPageProductsPerPage; if (command.PageNumber <= 0) command.PageNumber = 1; if (model.Q == null) model.Q = ""; model.Q = model.Q.Trim(); var categories = _categoryService.GetAllCategories(); if (categories.Count > 0) { model.AvailableCategories.Add(new SelectListItem() { Value = "0", Text = _localizationService.GetResource("Common.All") }); foreach(var c in categories) model.AvailableCategories.Add(new SelectListItem() { Value = c.Id.ToString(), Text = c.GetCategoryBreadCrumb(_categoryService), Selected = model.Cid == c.Id }); } var manufacturers = _manufacturerService.GetAllManufacturers(); if (manufacturers.Count > 0) { model.AvailableManufacturers.Add(new SelectListItem() { Value = "0", Text = _localizationService.GetResource("Common.All") }); foreach (var m in manufacturers) model.AvailableManufacturers.Add(new SelectListItem() { Value = m.Id.ToString(), Text = m.Name, Selected = model.Mid == m.Id }); } IPagedList<Product> products = new PagedList<Product>(new List<Product>(), 0, 1); // only search if query string search keyword is set (used to avoid searching or displaying search term min length error message on /search page load) if (Request.Params["Q"] != null) { if (model.Q.Length < _catalogSettings.ProductSearchTermMinimumLength) { model.Warning = string.Format(_localizationService.GetResource("Search.SearchTermMinimumLengthIsNCharacters"), _catalogSettings.ProductSearchTermMinimumLength); } else { var categoryIds = new List<int>(); int manufacturerId = 0; decimal? minPriceConverted = null; decimal? maxPriceConverted = null; bool searchInDescriptions = false; if (model.As) { //advanced search var categoryId = model.Cid; if (categoryId > 0) { categoryIds.Add(categoryId); if (model.Isc) { //include subcategories categoryIds.AddRange(GetChildCategoryIds(categoryId)); } } manufacturerId = model.Mid; //min price if (!string.IsNullOrEmpty(model.Pf)) { decimal minPrice = decimal.Zero; if (decimal.TryParse(model.Pf, out minPrice)) minPriceConverted = _currencyService.ConvertToPrimaryStoreCurrency(minPrice, _workContext.WorkingCurrency); } //max price if (!string.IsNullOrEmpty(model.Pt)) { decimal maxPrice = decimal.Zero; if (decimal.TryParse(model.Pt, out maxPrice)) maxPriceConverted = _currencyService.ConvertToPrimaryStoreCurrency(maxPrice, _workContext.WorkingCurrency); } searchInDescriptions = model.Sid; } //products IList<int> filterableSpecificationAttributeOptionIds = null; products = _productService.SearchProducts(categoryIds, manufacturerId, null, minPriceConverted, maxPriceConverted, 0, model.Q, searchInDescriptions, _workContext.WorkingLanguage.Id, null, ProductSortingEnum.Position, command.PageNumber - 1, command.PageSize, false, out filterableSpecificationAttributeOptionIds); model.Products = products.Select(x => PrepareProductOverviewModel(x)).ToList(); model.NoResults = !model.Products.Any(); } } model.PagingFilteringContext.LoadPagedList(products); return View(model); }
public ActionResult Search(SearchModel model, SearchPagingFilteringModel command) { if (model == null) model = new SearchModel(); // 'Continue shopping' URL _genericAttributeService.SaveAttribute(_services.WorkContext.CurrentCustomer, SystemCustomerAttributeNames.LastContinueShoppingPage, _services.WebHelper.GetThisPageUrl(false), _services.StoreContext.CurrentStore.Id); if (command.PageSize <= 0) command.PageSize = _catalogSettings.SearchPageProductsPerPage; if (command.PageNumber <= 0) command.PageNumber = 1; if (command.OrderBy == (int)ProductSortingEnum.Initial) { command.OrderBy = (int)_catalogSettings.DefaultSortOrder; } _helper.PreparePagingFilteringModel(model.PagingFilteringContext, command, new PageSizeContext { AllowCustomersToSelectPageSize = _catalogSettings.ProductSearchAllowCustomersToSelectPageSize, PageSize = _catalogSettings.SearchPageProductsPerPage, PageSizeOptions = _catalogSettings.ProductSearchPageSizeOptions }); if (model.Q == null) model.Q = ""; model.Q = model.Q.Trim(); // Build AvailableCategories // first empty entry model.AvailableCategories.Add(new SelectListItem { Value = "0", Text = T("Common.All") }); var navModel = _helper.PrepareCategoryNavigationModel(0, 0); navModel.Root.TraverseTree((node) => { if (node.IsRoot) return; int id = node.Value.EntityId; var breadcrumb = node.GetBreadcrumb().Select(x => x.Text).ToArray(); model.AvailableCategories.Add(new SelectListItem { Value = id.ToString(), Text = String.Join(" > ", breadcrumb), Selected = model.Cid == id }); }); var manufacturers = _manufacturerService.GetAllManufacturers(); if (manufacturers.Count > 0) { model.AvailableManufacturers.Add(new SelectListItem { Value = "0", Text = T("Common.All") }); foreach (var m in manufacturers) model.AvailableManufacturers.Add(new SelectListItem { Value = m.Id.ToString(), Text = m.GetLocalized(x => x.Name), Selected = model.Mid == m.Id }); } IPagedList<Product> products = new PagedList<Product>(new List<Product>(), 0, 1); // only search if query string search keyword is set (used to avoid searching or displaying search term min length error message on /search page load) if (Request.Params["Q"] != null) { if (model.Q.Length < _catalogSettings.ProductSearchTermMinimumLength) { model.Warning = string.Format(T("Search.SearchTermMinimumLengthIsNCharacters"), _catalogSettings.ProductSearchTermMinimumLength); } else { var categoryIds = new List<int>(); int manufacturerId = 0; decimal? minPriceConverted = null; decimal? maxPriceConverted = null; bool searchInDescriptions = false; if (model.As) { // advanced search var categoryId = model.Cid; if (categoryId > 0) { categoryIds.Add(categoryId); if (model.Isc) { // include subcategories categoryIds.AddRange(_helper.GetChildCategoryIds(categoryId)); } } manufacturerId = model.Mid; // min price if (!string.IsNullOrEmpty(model.Pf)) { decimal minPrice = decimal.Zero; if (decimal.TryParse(model.Pf, out minPrice)) minPriceConverted = _currencyService.ConvertToPrimaryStoreCurrency(minPrice, _services.WorkContext.WorkingCurrency); } // max price if (!string.IsNullOrEmpty(model.Pt)) { decimal maxPrice = decimal.Zero; if (decimal.TryParse(model.Pt, out maxPrice)) maxPriceConverted = _currencyService.ConvertToPrimaryStoreCurrency(maxPrice, _services.WorkContext.WorkingCurrency); } searchInDescriptions = model.Sid; } //var searchInProductTags = false; var searchInProductTags = searchInDescriptions; //products var ctx = new ProductSearchContext(); ctx.CategoryIds = categoryIds; ctx.ManufacturerId = manufacturerId; ctx.PriceMin = minPriceConverted; ctx.PriceMax = maxPriceConverted; ctx.Keywords = model.Q; ctx.SearchDescriptions = searchInDescriptions; ctx.SearchSku = !_catalogSettings.SuppressSkuSearch; ctx.SearchProductTags = searchInProductTags; ctx.LanguageId = _services.WorkContext.WorkingLanguage.Id; ctx.OrderBy = (ProductSortingEnum)command.OrderBy; // ProductSortingEnum.Position; ctx.PageIndex = command.PageNumber - 1; ctx.PageSize = command.PageSize; ctx.StoreId = _services.StoreContext.CurrentStoreIdIfMultiStoreMode; ctx.VisibleIndividuallyOnly = true; products = _productService.SearchProducts(ctx); model.Products = _helper.PrepareProductOverviewModels( products, prepareColorAttributes: true, prepareManufacturers: command.ViewMode.IsCaseInsensitiveEqual("list")).ToList(); model.NoResults = !model.Products.Any(); } } model.PagingFilteringContext.LoadPagedList(products); return View(model); }
public ActionResult Search(SearchModel model, SearchPagingFilteringModel command) { if (model == null) model = new SearchModel(); //'Continue shopping' URL _genericAttributeService.SaveAttribute(_workContext.CurrentCustomer, SystemCustomerAttributeNames.LastContinueShoppingPage, _webHelper.GetThisPageUrl(false), _storeContext.CurrentStore.Id); if (command.PageSize <= 0) command.PageSize = _catalogSettings.SearchPageProductsPerPage; if (command.PageNumber <= 0) command.PageNumber = 1; if (model.Q == null) model.Q = ""; model.Q = model.Q.Trim(); var customerRolesIds = _workContext.CurrentCustomer.CustomerRoles .Where(cr => cr.Active).Select(cr => cr.Id).ToList(); string cacheKey = string.Format(ModelCacheEventConsumer.SEARCH_CATEGORIES_MODEL_KEY, _workContext.WorkingLanguage.Id, string.Join(",", customerRolesIds), _storeContext.CurrentStore.Id); var categories = _cacheManager.Get(cacheKey, () => { var categoriesModel = new List<SearchPagingFilteringModel.CategoryModel>(); //all categories foreach (var c in _categoryService.GetAllCategories()) { //generate full category name (breadcrumb) string categoryBreadcrumb= ""; var breadcrumb = c.GetCategoryBreadCrumb(_categoryService, _aclService, _storeMappingService); for (int i = 0; i <= breadcrumb.Count - 1; i++) { categoryBreadcrumb += breadcrumb[i].GetLocalized(x => x.Name); if (i != breadcrumb.Count - 1) categoryBreadcrumb += " >> "; } categoriesModel.Add(new SearchPagingFilteringModel.CategoryModel() { Id = c.Id, Breadcrumb = categoryBreadcrumb }); } return categoriesModel; }); if (categories.Count > 0) { //first empty entry model.AvailableCategories.Add(new SelectListItem() { Value = "0", Text = _localizationService.GetResource("Common.All") }); //all other categories foreach (var c in categories) { model.AvailableCategories.Add(new SelectListItem() { Value = c.Id.ToString(), Text = c.Breadcrumb, Selected = model.Cid == c.Id }); } } var manufacturers = _manufacturerService.GetAllManufacturers(); if (manufacturers.Count > 0) { model.AvailableManufacturers.Add(new SelectListItem() { Value = "0", Text = _localizationService.GetResource("Common.All") }); foreach (var m in manufacturers) model.AvailableManufacturers.Add(new SelectListItem() { Value = m.Id.ToString(), Text = m.GetLocalized(x => x.Name), Selected = model.Mid == m.Id }); } IPagedList<Product> products = new PagedList<Product>(new List<Product>(), 0, 1); // only search if query string search keyword is set (used to avoid searching or displaying search term min length error message on /search page load) if (Request.Params["Q"] != null) { if (model.Q.Length < _catalogSettings.ProductSearchTermMinimumLength) { model.Warning = string.Format(_localizationService.GetResource("Search.SearchTermMinimumLengthIsNCharacters"), _catalogSettings.ProductSearchTermMinimumLength); } else { var categoryIds = new List<int>(); int manufacturerId = 0; decimal? minPriceConverted = null; decimal? maxPriceConverted = null; bool searchInDescriptions = false; if (model.As) { //advanced search var categoryId = model.Cid; if (categoryId > 0) { categoryIds.Add(categoryId); if (model.Isc) { //include subcategories categoryIds.AddRange(GetChildCategoryIds(categoryId)); } } manufacturerId = model.Mid; //min price if (!string.IsNullOrEmpty(model.Pf)) { decimal minPrice = decimal.Zero; if (decimal.TryParse(model.Pf, out minPrice)) minPriceConverted = _currencyService.ConvertToPrimaryStoreCurrency(minPrice, _workContext.WorkingCurrency); } //max price if (!string.IsNullOrEmpty(model.Pt)) { decimal maxPrice = decimal.Zero; if (decimal.TryParse(model.Pt, out maxPrice)) maxPriceConverted = _currencyService.ConvertToPrimaryStoreCurrency(maxPrice, _workContext.WorkingCurrency); } searchInDescriptions = model.Sid; } //var searchInProductTags = false; var searchInProductTags = searchInDescriptions; //products products = _productService.SearchProducts( categoryIds: categoryIds, manufacturerId: manufacturerId, storeId: _storeContext.CurrentStore.Id, visibleIndividuallyOnly: true, priceMin: minPriceConverted, priceMax: maxPriceConverted, keywords:model.Q, searchDescriptions: searchInDescriptions, searchSku: searchInDescriptions, searchProductTags: searchInProductTags, languageId:_workContext.WorkingLanguage.Id, pageIndex: command.PageNumber - 1, pageSize: command.PageSize); model.Products = PrepareProductOverviewModels(products).ToList(); model.NoResults = !model.Products.Any(); //event _eventPublisher.Publish(new ProductSearchEvent() { SearchTerm = model.Q, SearchInDescriptions = searchInDescriptions, CategoryIds = categoryIds, ManufacturerId = manufacturerId, WorkingLanguageId = _workContext.WorkingLanguage.Id }); } } model.PagingFilteringContext.LoadPagedList(products); return View(model); }
public ActionResult Search(SearchModel model, SearchPagingFilteringModel command) { if (model == null) { model = new SearchModel(); } // 'Continue shopping' URL _genericAttributeService.SaveAttribute(_services.WorkContext.CurrentUser, SystemUserAttributeNames.LastContinueShoppingPage, _services.WebHelper.GetThisPageUrl(false), _services.SiteContext.CurrentSite.Id); if (command.PageSize <= 0) { command.PageSize = _catalogSettings.SearchPageArticlesPerPage; } if (command.PageNumber <= 0) { command.PageNumber = 1; } _helper.PreparePagingFilteringModel(model.PagingFilteringContext, command, new PageSizeContext { AllowUsersToSelectPageSize = _catalogSettings.ArticleSearchAllowUsersToSelectPageSize, PageSize = _catalogSettings.SearchPageArticlesPerPage, PageSizeOptions = _catalogSettings.ArticleSearchPageSizeOptions }); if (model.Q == null) { model.Q = ""; } model.Q = model.Q.Trim(); // Build AvailableCategories // first empty entry model.AvailableArticleCategories.Add(new SelectListItem { Value = "0", Text = T("Common.All") }); var navModel = _helper.PrepareCategoryNavigationModel(0, 0); navModel.Root.TraverseTree((node) => { if (node.IsRoot) { return; } int id = node.Value.EntityId; var breadcrumb = node.GetBreadcrumb().Select(x => x.Text).ToArray(); model.AvailableArticleCategories.Add(new SelectListItem { Value = id.ToString(), Text = String.Join(" > ", breadcrumb), Selected = model.Cid == id }); }); IPagedList <Article> articles = new PagedList <Article>(new List <Article>(), 0, 1); // only search if query string search keyword is set (used to avoid searching or displaying search term min length error message on /search page load) if (Request.Params["Q"] != null) { if (model.Q.Length < _catalogSettings.ArticleSearchTermMinimumLength) { model.Warning = string.Format(T("Search.SearchTermMinimumLengthIsNCharacters"), _catalogSettings.ArticleSearchTermMinimumLength); } else { var categoryIds = new List <int>(); bool searchInDescriptions = false; if (model.As) { // advanced search var categoryId = model.Cid; if (categoryId > 0) { categoryIds.Add(categoryId); if (model.Isc) { // include subcategories categoryIds.AddRange(_helper.GetChildCategoryIds(categoryId)); } } searchInDescriptions = model.Sid; } //var searchInArticleTags = false; var searchInArticleTags = searchInDescriptions; //articles #region Text Search var ctx = new ArticleSearchContext(); ctx.CategoryIds = categoryIds; ctx.Keywords = model.Q; ctx.SearchDescriptions = searchInDescriptions; ctx.SearchArticleTags = searchInArticleTags; ctx.LanguageId = _services.WorkContext.WorkingLanguage.Id; ctx.OrderBy = (ArticleSortingEnum)command.OrderBy; // ArticleSortingEnum.Position; ctx.PageIndex = command.PageNumber - 1; ctx.PageSize = command.PageSize; ctx.SiteId = _services.SiteContext.CurrentSiteIdIfMultiSiteMode; ctx.VisibleIndividuallyOnly = true; articles = _articleService.SearchArticles(ctx); #endregion #region Lucene //var searchQuery = new SearchQuery(model.Q) // { // NumberOfHitsToReturn = command.PageSize, // ReturnFromPosition = command.PageSize * (command.PageNumber - 1) // }; //// Perform the searh //var result = this._searchProvider.Value.Search(searchQuery); #endregion model.Articles = _helper.PrepareArticlePostModels( articles).ToList(); model.NoResults = !model.Articles.Any(); } } model.PagingFilteringContext.LoadPagedList(articles); return(View(model)); }
public SearchModel() { PagingFilteringContext = new SearchPagingFilteringModel(); Products = new List <ProductOverviewModel>(); }
public ActionResult Search(SearchModel model, SearchPagingFilteringModel command) { if (model == null) model = new SearchModel(); //'Continue shopping' URL _genericAttributeService.SaveAttribute(_workContext.CurrentCustomer, SystemCustomerAttributeNames.LastContinueShoppingPage, _webHelper.GetThisPageUrl(false), _storeContext.CurrentStore.Id); if (command.PageSize <= 0) command.PageSize = _catalogSettings.SearchPageProductsPerPage; //_catalogSettings.SearchPageProductsPerPage; if (command.PageNumber <= 0) command.PageNumber = 1; // codehint: sm-edit PreparePagingFilteringModel(model.PagingFilteringContext, command, new PageSizeContext { AllowCustomersToSelectPageSize = _catalogSettings.ProductSearchAllowCustomersToSelectPageSize, PageSize = _catalogSettings.SearchPageProductsPerPage, PageSizeOptions = _catalogSettings.ProductSearchPageSizeOptions }); // codehint: sm-edit if (model.Q == null) model.Q = ""; model.Q = model.Q.Trim(); // Build AvailableCategories // first empty entry model.AvailableCategories.Add(new SelectListItem() { Value = "0", Text = T("Common.All") }); var navModel = GetCategoryNavigationModel(0, 0); navModel.Root.TraverseTree((node) => { if (node.IsRoot) return; int id = node.Value.Id; var breadcrumb = new List<string>(); while (node != null && !node.IsRoot) { breadcrumb.Add(node.Value.Name); node = node.Parent; } breadcrumb.Reverse(); model.AvailableCategories.Add(new SelectListItem() { Value = id.ToString(), Text = String.Join(" > ", breadcrumb), Selected = model.Cid == id }); }); #region Obsolete //var categories = _categoryService.GetAllCategories(); //// Perf! //var mappedCatgories = categories.ToDictionary(x => x.Id); //if (categories.Count > 0) //{ // //first empty entry // model.AvailableCategories.Add(new SelectListItem() // { // Value = "0", // Text = _localizationService.GetResource("Common.All") // }); // //all other categories // foreach (var c in categories) // { // //generate full category name (breadcrumb) // string fullCategoryBreadcrumbName = ""; // var breadcrumb = GetCategoryBreadCrumb(c, mappedCatgories); // for (int i = 0; i <= breadcrumb.Count - 1; i++) // { // fullCategoryBreadcrumbName += breadcrumb[i].GetLocalized(x => x.Name); // if (i != breadcrumb.Count - 1) // fullCategoryBreadcrumbName += " >> "; // } // model.AvailableCategories.Add(new SelectListItem() // { // Value = c.Id.ToString(), // Text = fullCategoryBreadcrumbName, // Selected = model.Cid == c.Id // }); // } //} #endregion var manufacturers = _manufacturerService.GetAllManufacturers(); if (manufacturers.Count > 0) { model.AvailableManufacturers.Add(new SelectListItem() { Value = "0", Text = T("Common.All") }); foreach (var m in manufacturers) model.AvailableManufacturers.Add(new SelectListItem() { Value = m.Id.ToString(), Text = m.GetLocalized(x => x.Name), Selected = model.Mid == m.Id }); } IPagedList<Product> products = new PagedList<Product>(new List<Product>(), 0, 1); // only search if query string search keyword is set (used to avoid searching or displaying search term min length error message on /search page load) if (Request.Params["Q"] != null) { if (model.Q.Length < _catalogSettings.ProductSearchTermMinimumLength) { model.Warning = string.Format(T("Search.SearchTermMinimumLengthIsNCharacters"), _catalogSettings.ProductSearchTermMinimumLength); } else { var categoryIds = new List<int>(); int manufacturerId = 0; decimal? minPriceConverted = null; decimal? maxPriceConverted = null; bool searchInDescriptions = false; if (model.As) { //advanced search var categoryId = model.Cid; if (categoryId > 0) { categoryIds.Add(categoryId); if (model.Isc) { //include subcategories categoryIds.AddRange(GetChildCategoryIds(categoryId)); } } manufacturerId = model.Mid; //min price if (!string.IsNullOrEmpty(model.Pf)) { decimal minPrice = decimal.Zero; if (decimal.TryParse(model.Pf, out minPrice)) minPriceConverted = _currencyService.ConvertToPrimaryStoreCurrency(minPrice, _workContext.WorkingCurrency); } //max price if (!string.IsNullOrEmpty(model.Pt)) { decimal maxPrice = decimal.Zero; if (decimal.TryParse(model.Pt, out maxPrice)) maxPriceConverted = _currencyService.ConvertToPrimaryStoreCurrency(maxPrice, _workContext.WorkingCurrency); } searchInDescriptions = model.Sid; } //var searchInProductTags = false; var searchInProductTags = searchInDescriptions; //products var ctx = new ProductSearchContext(); ctx.CategoryIds = categoryIds; ctx.ManufacturerId = manufacturerId; ctx.PriceMin = minPriceConverted; ctx.PriceMax = maxPriceConverted; ctx.Keywords = model.Q; ctx.SearchDescriptions = searchInDescriptions; ctx.SearchSku = !_catalogSettings.SuppressSkuSearch; ctx.SearchProductTags = searchInProductTags; ctx.LanguageId = _workContext.WorkingLanguage.Id; ctx.OrderBy = (ProductSortingEnum)command.OrderBy; // ProductSortingEnum.Position; // codehint: sm-edit ctx.PageIndex = command.PageNumber - 1; ctx.PageSize = command.PageSize; ctx.StoreId = _storeContext.CurrentStoreIdIfMultiStoreMode; ctx.VisibleIndividuallyOnly = true; products = _productService.SearchProducts(ctx); model.Products = PrepareProductOverviewModels(products, prepareColorAttributes: true).ToList(); model.NoResults = !model.Products.Any(); } } model.PagingFilteringContext.LoadPagedList(products); return View(model); }
public SearchModel() { PagingFilteringContext = new SearchPagingFilteringModel(); Articles = new List <ArticlePostModel>(); this.AvailableArticleCategories = new List <SelectListItem>(); }