protected virtual void ConvertPrice(CatalogSearchQuery query, RouteData routeData, string origin)
        {
            string price;
            double?minPrice = null;
            double?maxPrice = null;

            if (GetValueFor(query, "p", FacetGroupKind.Price, out price) && TryParseRange(price, out minPrice, out maxPrice))
            {
                var currency = _services.WorkContext.WorkingCurrency;

                if (minPrice.HasValue)
                {
                    // TODO: (mc) Why the heck did I convert this??!!
                    //minPrice = _currencyService.ConvertToPrimaryStoreCurrency(minPrice.Value, currency);
                }

                if (maxPrice.HasValue)
                {
                    //maxPrice = _currencyService.ConvertToPrimaryStoreCurrency(maxPrice.Value, currency);
                }

                if (minPrice.HasValue && maxPrice.HasValue && minPrice > maxPrice)
                {
                    var tmp = minPrice;
                    minPrice = maxPrice;
                    maxPrice = tmp;
                }

                if (minPrice.HasValue || maxPrice.HasValue)
                {
                    query.PriceBetween((decimal?)minPrice, (decimal?)maxPrice);
                }
            }

            AddFacet(query, FacetGroupKind.Price, false, FacetSorting.DisplayOrder, descriptor =>
            {
                if (minPrice.HasValue || maxPrice.HasValue)
                {
                    descriptor.AddValue(new FacetValue(
                                            minPrice,
                                            maxPrice,
                                            IndexTypeCode.Double,
                                            minPrice.HasValue,
                                            maxPrice.HasValue)
                    {
                        IsSelected = true
                    });
                }
            });
        }
예제 #2
0
        protected virtual void ConvertPrice(CatalogSearchQuery query, string origin)
        {
            double?minPrice = null;
            double?maxPrice = null;
            var    alias    = _catalogSearchQueryAliasMapper.GetCommonFacetAliasByGroupKind(FacetGroupKind.Price, query.LanguageId ?? 0);

            if (TryGetValueFor(alias ?? "p", out string price) && TryParseRange(price, out minPrice, out maxPrice))
            {
                // TODO: (mc) Why the heck did I convert this??!!
                //var currency = _services.WorkContext.WorkingCurrency;

                //if (minPrice.HasValue)
                //{
                //    minPrice = _currencyService.ConvertToPrimaryStoreCurrency(minPrice.Value, currency);
                //}

                //if (maxPrice.HasValue)
                //{
                //    maxPrice = _currencyService.ConvertToPrimaryStoreCurrency(maxPrice.Value, currency);
                //}

                if (minPrice.HasValue && maxPrice.HasValue && minPrice > maxPrice)
                {
                    var tmp = minPrice;
                    minPrice = maxPrice;
                    maxPrice = tmp;
                }

                if (minPrice.HasValue || maxPrice.HasValue)
                {
                    query.PriceBetween((decimal?)minPrice, (decimal?)maxPrice);
                }
            }

            AddFacet(query, FacetGroupKind.Price, false, FacetSorting.DisplayOrder, descriptor =>
            {
                if (minPrice.HasValue || maxPrice.HasValue)
                {
                    descriptor.AddValue(new FacetValue(
                                            minPrice,
                                            maxPrice,
                                            IndexTypeCode.Double,
                                            minPrice.HasValue,
                                            maxPrice.HasValue)
                    {
                        IsSelected = true
                    });
                }
            });
        }