private IList <FacetViewModel> MapFacetsByManualSelection(string categoryIdsString, string productIdsString)
        {
            var categoryIds = categoryIdsString?.Split(',').Select(x => Convert.ToInt32(x)).ToList() ?? new List <int>();
            var productIds  = productIdsString?.Split(',').Select(x => Convert.ToInt32(x)).ToList() ?? new List <int>();

            var facetsResolver    = new FacetResolver(this.queryStringBlackList);
            var facetsForQuerying = facetsResolver.GetFacetsFromQueryString();

            return(this.MapToFacetsViewModel(SearchLibrary.FacetedQuery()
                                             .Where(x => x.CategoryIds.In(categoryIds) || x.Id.In(productIds)).WithFacets(facetsForQuerying).ToFacets().ToList()));
        }
        private IList <FacetViewModel> GetAllFacets(Category category)
        {
            var facetsResolver    = new FacetResolver(this.queryStringBlackList);
            var facetsForQuerying = facetsResolver.GetFacetsFromQueryString();
            IList <UCommerce.Search.Facets.Facet> allFacets;

            if (category != null)
            {
                allFacets = SearchLibrary.GetFacetsFor(category, facetsForQuerying);
            }
            else
            {
                allFacets = SearchLibrary.FacetedQuery()
                            .WithFacets(facetsForQuerying)
                            .ToFacets()
                            .ToList();
            }

            return(this.MapToFacetsViewModel(allFacets));
        }
Exemple #3
0
        private IQueryable <Product> ApplyManualSelection(List <int> productIds, List <int> categoryIds)
        {
            var productsQuery = SearchLibrary.FacetedQuery();

            var products = new List <Product>();

            products.AddRange(this.GetProductsFromSelectedCategoryIds(categoryIds));
            products.AddRange(this.GetProductsFromSelectedProductIds(productIds));

            var facetsResolver = new FacetResolver(this.queryStringBlackList);

            List <UCommerce.Documents.Product> productsFromFacets = SearchLibrary.FacetedQuery()
                                                                    .Where(x => x.CategoryIds.In(categoryIds) || x.Id.In(productIds))
                                                                    .WithFacets(facetsResolver.GetFacetsFromQueryString())
                                                                    .ToList();

            if (!productsFromFacets.Any())
            {
                return(products.AsQueryable());
            }

            return(products.Where(x => productsFromFacets.Any(y => x.Sku == y.Sku)).AsQueryable());
        }