protected virtual IList <IFilter> GetFilters(CategorySearchCriteria criteria) { var result = new List <IFilter>(); if (!string.IsNullOrEmpty(criteria.SearchPhrase)) { var parseResult = _searchPhraseParser.Parse(criteria.SearchPhrase); criteria.SearchPhrase = parseResult.SearchPhrase; result.AddRange(parseResult.Filters); } if (criteria.ObjectIds != null) { result.Add(new IdsFilter { Values = criteria.ObjectIds }); } if (!string.IsNullOrEmpty(criteria.CatalogId)) { result.Add(FiltersHelper.CreateTermFilter("catalog", criteria.CatalogId.ToLowerInvariant())); } result.Add(FiltersHelper.CreateOutlineFilter(criteria)); var terms = criteria.GetTerms(); result.AddRange(terms.Select(term => FiltersHelper.CreateTermFilter(term.Key, term.Values))); return(result); }
protected virtual IList <IFilter> GetPermanentFilters(ProductSearchCriteria criteria) { var result = new List <IFilter>(); if (!string.IsNullOrEmpty(criteria.SearchPhrase)) { var parseResult = _searchPhraseParser.Parse(criteria.SearchPhrase); criteria.SearchPhrase = parseResult.SearchPhrase; result.AddRange(parseResult.Filters); } if (criteria.ObjectIds != null) { result.Add(new IdsFilter { Values = criteria.ObjectIds }); } if (!string.IsNullOrEmpty(criteria.CatalogId)) { result.Add(FiltersHelper.CreateTermFilter("catalog", criteria.CatalogId.ToLowerInvariant())); } result.Add(FiltersHelper.CreateOutlineFilter(criteria)); result.Add(FiltersHelper.CreateDateRangeFilter("startdate", criteria.StartDateFrom, criteria.StartDate, false, true)); if (criteria.EndDate != null) { result.Add(FiltersHelper.CreateDateRangeFilter("enddate", criteria.EndDate, null, false, false)); } if (!criteria.ClassTypes.IsNullOrEmpty()) { result.Add(FiltersHelper.CreateTermFilter("__type", criteria.ClassTypes)); } if (!criteria.WithHidden) { result.Add(FiltersHelper.CreateTermFilter("status", "visible")); } if (criteria.PriceRange != null) { var range = criteria.PriceRange; result.Add(FiltersHelper.CreatePriceRangeFilter(criteria.Currency, null, range.Lower, range.Upper, range.IncludeLower, range.IncludeUpper)); } if (criteria.GeoDistanceFilter != null) { result.Add(criteria.GeoDistanceFilter); } return(result); }