Esempio n. 1
0
        protected virtual NameValueCollection GetQueryParts(Facet facet)
        {
            string name  = null;
            string value = null;
            int    entityId;

            var group = facet.FacetGroup;
            var val   = facet.Value;

            var result = new NameValueCollection(2);

            switch (group.Kind)
            {
            case FacetGroupKind.Attribute:
                if (facet.Value.TypeCode == IndexTypeCode.Double)
                {
                    value = "{0}~{1}".FormatInvariant(
                        val.Value != null ? ((double)val.Value).ToString(CultureInfo.InvariantCulture) : "",
                        val.UpperValue != null ? ((double)val.UpperValue).ToString(CultureInfo.InvariantCulture) : "");
                }
                else
                {
                    entityId = val.Value.Convert <int>();
                    value    = _mapper.GetAttributeOptionAliasById(entityId, _languageId) ?? "opt" + entityId;
                }
                name = _mapper.GetAttributeAliasById(val.ParentId, _languageId) ?? "attr" + val.ParentId;
                result.Add(name, value);
                break;

            case FacetGroupKind.Variant:
                entityId = val.Value.Convert <int>();
                name     = _mapper.GetVariantAliasById(val.ParentId, _languageId) ?? "vari" + val.ParentId;
                value    = _mapper.GetVariantOptionAliasById(entityId, _languageId) ?? "opt" + entityId;
                result.Add(name, value);
                break;

            case FacetGroupKind.Category:
            case FacetGroupKind.Brand:
            case FacetGroupKind.Price:
            case FacetGroupKind.Rating:
            case FacetGroupKind.DeliveryTime:
            case FacetGroupKind.Availability:
            case FacetGroupKind.NewArrivals:
                value = val.ToString();
                if (value.HasValue())
                {
                    name = _mapper.GetCommonFacetAliasByGroupKind(group.Kind, _languageId) ?? _queryNames[group.Kind];
                    result.Add(name, value);
                }

                break;
            }

            return(result);
        }
Esempio n. 2
0
        protected override Dictionary <string, string> GetQueryParts(Facet facet)
        {
            var    result = new Dictionary <string, string>();
            string name;
            string value;
            int    entityId;
            var    val        = facet.Value;
            var    languageId = _workContext.WorkingLanguage.Id;

            switch (facet.FacetGroup.Kind)
            {
            case FacetGroupKind.Attribute:
                if (facet.Value.TypeCode == IndexTypeCode.Double)
                {
                    value = "{0}~{1}".FormatInvariant(
                        val.Value != null ? ((double)val.Value).ToString(CultureInfo.InvariantCulture) : string.Empty,
                        val.UpperValue != null ? ((double)val.UpperValue).ToString(CultureInfo.InvariantCulture) : string.Empty);
                }
                else
                {
                    entityId = val.Value.Convert <int>();
                    value    = _catalogAliasMapper.GetAttributeOptionAliasById(entityId, languageId) ?? "opt" + entityId;
                }
                name         = _catalogAliasMapper.GetAttributeAliasById(val.ParentId, languageId) ?? "attr" + val.ParentId;
                result[name] = value;
                break;

            case FacetGroupKind.Variant:
                entityId     = val.Value.Convert <int>();
                name         = _catalogAliasMapper.GetVariantAliasById(val.ParentId, languageId) ?? "vari" + val.ParentId;
                value        = _catalogAliasMapper.GetVariantOptionAliasById(entityId, languageId) ?? "opt" + entityId;
                result[name] = value;
                break;

            case FacetGroupKind.Category:
            case FacetGroupKind.Brand:
            case FacetGroupKind.Price:
            case FacetGroupKind.Rating:
            case FacetGroupKind.DeliveryTime:
            case FacetGroupKind.Availability:
            case FacetGroupKind.NewArrivals:
                value = val.ToString();
                if (value.HasValue())
                {
                    name         = _catalogAliasMapper.GetCommonFacetAliasByGroupKind(facet.FacetGroup.Kind, languageId) ?? _queryNames[facet.FacetGroup.Kind];
                    result[name] = value;
                }
                break;
            }

            return(result);
        }