Esempio n. 1
0
        private IEnumerable <FacetGroupOption> BuildFacetGroupList(IContent currentContent, FilterOptionViewModel filterOptions)
        {
            var query = BuildBaseQuery(currentContent, filterOptions);

            query = query.Take(0);
            query = query.TermsFacetFor(p => p.ParentName, r => r.Size = MaxNumberOfFacets);
            query = query.TermsFacetFor(p => p.AvailableColorList, r => r.Size = MaxNumberOfFacets);
            query = query.TermsFacetFor(p => p.AvailableSizeList, r => r.Size = MaxNumberOfFacets);
            query = query.TermsFacetFor(p => p.Brand, r => r.Size = MaxNumberOfFacets);
            query = query.TermsFacetFor(p => p.TopCategory, r => r.Size = MaxNumberOfFacets);
            IContentResult <BaseProduct> results = query.GetContentResult();

            var facetGroups = new List <FacetGroupOption>();

            AddFacet(facetGroups, results.TermsFacetFor(p => p.ParentName),
                     filterOptions.FacetGroups.FirstOrDefault(fg => fg.GroupFieldName.Equals(Constants.Product.Categories)),
                     Constants.Product.Categories);
            AddFacet(facetGroups, results.TermsFacetFor(p => p.AvailableColorList),
                     filterOptions.FacetGroups.FirstOrDefault(fg => fg.GroupFieldName.Equals(Constants.Product.AvailableColors)),
                     Constants.Product.AvailableColors);
            AddFacet(facetGroups, results.TermsFacetFor(p => p.AvailableSizeList),
                     filterOptions.FacetGroups.FirstOrDefault(fg => fg.GroupFieldName.Equals(Constants.Product.AvailableSizes)),
                     Constants.Product.AvailableSizes);
            AddFacet(facetGroups, results.TermsFacetFor(p => p.Brand),
                     filterOptions.FacetGroups.FirstOrDefault(fg => fg.GroupFieldName.Equals(Constants.Product.Brand)),
                     Constants.Product.Brand);
            AddFacet(facetGroups, results.TermsFacetFor(p => p.TopCategory),
                     filterOptions.FacetGroups.FirstOrDefault(fg => fg.GroupFieldName.Equals(Constants.Product.TopCategory)),
                     Constants.Product.TopCategory);

            return(facetGroups);
        }