Пример #1
0
 protected bool GetValueFor <T>(CatalogSearchQuery query, string key, FacetGroupKind kind, out T value)
 {
     return(GetValueFor(_catalogSearchQueryAliasMapper.GetCommonFacetAliasByGroupKind(kind, query.LanguageId ?? 0) ?? key, out value));
 }
Пример #2
0
        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)
                {
                    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(FacetDescriptor.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);
        }
Пример #3
0
 protected string CreateSettingKey(FacetGroupKind kind, int languageId)
 {
     return($"FacetGroupKind-{kind.ToString()}-Alias-{languageId}");
 }
Пример #4
0
        public string GetCommonFacetAliasByGroupKind(FacetGroupKind kind, int languageId)
        {
            var mappings = GetCommonFacetAliasByGroupKindMappings();

            return(mappings.Get(CreateSettingKey(kind, languageId)));
        }
Пример #5
0
 protected virtual bool GetValueFor <T>(ForumSearchQuery query, string key, FacetGroupKind kind, out T value)
 {
     return(TryGetValueFor(_forumSearchQueryAliasMapper.GetCommonFacetAliasByGroupKind(kind, query.LanguageId ?? 0) ?? key, out value));
 }
        public string GetCommonFacetAliasByGroupKind(FacetGroupKind kind, int languageId)
        {
            var mappings = GetCommonFacetAliasByGroupKindMappings();

            return(mappings.Get(FacetUtility.GetFacetAliasSettingKey(kind, languageId, "Forum")));
        }