private void AddFacet(
            ForumSearchQuery query,
            FacetGroupKind kind,
            bool isMultiSelect,
            FacetSorting sorting,
            Action <FacetDescriptor> addValues)
        {
            string fieldName;
            var    displayOrder = 0;

            switch (kind)
            {
            case FacetGroupKind.Forum:
                if (_searchSettings.ForumDisabled)
                {
                    return;
                }
                fieldName    = "forumid";
                displayOrder = _searchSettings.ForumDisplayOrder;
                break;

            case FacetGroupKind.Customer:
                if (_searchSettings.CustomerDisabled)
                {
                    return;
                }
                fieldName    = "customerid";
                displayOrder = _searchSettings.CustomerDisplayOrder;
                break;

            case FacetGroupKind.Date:
                if (_searchSettings.DateDisabled)
                {
                    return;
                }
                fieldName    = "createdon";
                displayOrder = _searchSettings.DateDisplayOrder;
                break;

            default:
                throw new SmartException($"Unknown field name for facet group '{kind.ToString()}'");
            }

            var descriptor = new FacetDescriptor(fieldName);

            descriptor.Label           = _services.Localization.GetResource(FacetUtility.GetLabelResourceKey(kind) ?? kind.ToString());
            descriptor.IsMultiSelect   = isMultiSelect;
            descriptor.DisplayOrder    = displayOrder;
            descriptor.OrderBy         = sorting;
            descriptor.MinHitCount     = _searchSettings.FilterMinHitCount;
            descriptor.MaxChoicesCount = _searchSettings.FilterMaxChoicesCount;

            addValues(descriptor);
            query.WithFacet(descriptor);
        }
        private void AddFacet(
            CatalogSearchQuery query,
            FacetGroupKind kind,
            bool isMultiSelect,
            FacetSorting sorting,
            Action <FacetDescriptor> addValues)
        {
            string fieldName;
            var    displayOrder = 0;

            switch (kind)
            {
            case FacetGroupKind.Category:
                fieldName = _catalogSettings.IncludeFeaturedProductsInNormalLists ? "categoryid" : "notfeaturedcategoryid";
                break;

            case FacetGroupKind.Brand:
                if (_searchSettings.BrandDisabled)
                {
                    return;
                }
                fieldName    = "manufacturerid";
                displayOrder = _searchSettings.BrandDisplayOrder;
                break;

            case FacetGroupKind.Price:
                if (_searchSettings.PriceDisabled || !_services.Permissions.Authorize(StandardPermissionProvider.DisplayPrices))
                {
                    return;
                }
                fieldName    = "price";
                displayOrder = _searchSettings.PriceDisplayOrder;
                break;

            case FacetGroupKind.Rating:
                if (_searchSettings.RatingDisabled)
                {
                    return;
                }
                fieldName    = "rating";
                displayOrder = _searchSettings.RatingDisplayOrder;
                break;

            case FacetGroupKind.DeliveryTime:
                if (_searchSettings.DeliveryTimeDisabled)
                {
                    return;
                }
                fieldName    = "deliveryid";
                displayOrder = _searchSettings.DeliveryTimeDisplayOrder;
                break;

            case FacetGroupKind.Availability:
                if (_searchSettings.AvailabilityDisabled)
                {
                    return;
                }
                fieldName    = "available";
                displayOrder = _searchSettings.AvailabilityDisplayOrder;
                break;

            case FacetGroupKind.NewArrivals:
                if (_searchSettings.NewArrivalsDisabled)
                {
                    return;
                }
                fieldName    = "createdon";
                displayOrder = _searchSettings.NewArrivalsDisplayOrder;
                break;

            default:
                throw new SmartException($"Unknown field name for facet group '{kind.ToString()}'");
            }

            var descriptor = new FacetDescriptor(fieldName);

            descriptor.Label           = _services.Localization.GetResource(FacetUtility.GetLabelResourceKey(kind) ?? kind.ToString());
            descriptor.IsMultiSelect   = isMultiSelect;
            descriptor.DisplayOrder    = displayOrder;
            descriptor.OrderBy         = sorting;
            descriptor.MinHitCount     = _searchSettings.FilterMinHitCount;
            descriptor.MaxChoicesCount = _searchSettings.FilterMaxChoicesCount;

            addValues(descriptor);
            query.WithFacet(descriptor);
        }