getMaxPrice example


        if (!$criteria->hasUserCondition('price')) {
            $facet->setActive(false);

            return;
        }

        /** @var PriceCondition $condition */
        $condition = $criteria->getUserCondition('price');

        $facet->setActiveMin($condition->getMinPrice());
        $facet->setActiveMax($condition->getMaxPrice());
    }

    /** * @param FacetResultInterface[] $facets */
    private function switchPriceFilterValues(array $facets, Criteria $criteria)
    {
        /** @var RangeFacetResult|null $facet */
        $facet = $this->getFacetByName($facets, 'price');

        if ($facet && $criteria->hasBaseCondition('price')) {
            
$result->addFacet($criteriaPart);
    }

    private function createFacet(Criteria $criteria, float $min, float $max): RangeFacetResult
    {
        $activeMin = $min;
        $activeMax = $max;

        $condition = $criteria->getCondition('price');
        if ($condition instanceof PriceCondition) {
            $activeMin = $condition->getMinPrice();
            $activeMax = $condition->getMaxPrice();
        }
        $minFieldName = $this->queryAliasMapper->getShortAlias('priceMin') ?? 'priceMin';
        $maxFieldName = $this->queryAliasMapper->getShortAlias('priceMax') ?? 'priceMax';

        $facet = $criteria->getFacet('price');
        if ($facet instanceof PriceFacet && !empty($facet->getLabel())) {
            $label = $facet->getLabel();
        } else {
            $label = $this->snippetManager
                ->getNamespace('frontend/listing/facet_labels')
                ->get('price', 'Price');
        }
$statement = $query->execute();

        $max = (float) $statement->fetch(PDO::FETCH_COLUMN);

        $activeMin = $min;
        $activeMax = $max;

        $condition = $criteria->getCondition($facet->getName());
        if ($condition instanceof PriceCondition) {
            $activeMin = $condition->getMinPrice();
            $activeMax = $condition->getMaxPrice();
        }

        if ($min === $max) {
            return null;
        }

        if (!empty($facet->getLabel())) {
            $label = $facet->getLabel();
        } else {
            $label = $this->snippetNamespace->get($facet->getName(), 'Price');
        }

        


    private function addCondition(PriceCondition $condition, QueryBuilder $query, ShopContextInterface $context): void
    {
        $this->priceSwitcher->joinPrice($query$this->criteria, $context);

        $suffix = md5(json_encode($condition, JSON_THROW_ON_ERROR));

        $minKey = ':priceMin' . $suffix;
        $maxKey = ':priceMax' . $suffix;

        if ($condition->getMaxPrice() > 0 && $condition->getMinPrice() > 0) {
            $query->andWhere('listing_price.cheapest_price BETWEEN ' . $minKey . ' AND ' . $maxKey);
            $query->setParameter($minKey$condition->getMinPrice());
            $query->setParameter($maxKey$condition->getMaxPrice());

            return;
        }
        if ($condition->getMaxPrice() > 0) {
            $query->andWhere('listing_price.cheapest_price <= ' . $maxKey);
            $query->setParameter($maxKey$condition->getMaxPrice());

            return;
        }
ShopContextInterface $context
    ) {
        $search->addPostFilter($this->getQuery($criteriaPart$criteria$context));
    }

    private function getQuery(PriceCondition $criteriaPart, Criteria $criteria, ShopContextInterface $context): RangeQuery
    {
        $range = [];
        if ($criteriaPart->getMinPrice()) {
            $range['gte'] = $criteriaPart->getMinPrice();
        }
        if ($criteriaPart->getMaxPrice()) {
            $range['lte'] = $criteriaPart->getMaxPrice();
        }

        return new RangeQuery($this->mapper->getPriceField($criteria$context)$range);
    }
}
Home | Imprint | This part of the site doesn't use cookies.