setFilter example

$connection
            ->expects(static::once())
            ->method('fetchOne')
            ->willReturn(current(array_column($filters, 'api_filter')));

        $criteria->setLimit(150);
        $criteria->addSorting(new FieldSorting('autoIncrement'));
        $filters = $criteria->getFilters();
        array_pop($filters);
        $criteria->resetFilters();
        $criteria->addFilter(...$filters);
        $criteria->setFilter('increment', new RangeFilter('autoIncrement', [RangeFilter::GTE => 0]));

        $definition = new ProductDefinition();
        $repository = new StaticEntityRepository([
            function DCriteria $actualCriteria, Context $actualContext) use ($criteria$context$ids): array {
                static::assertEquals($criteria$actualCriteria);
                static::assertEquals($context$actualContext);

                return $ids;
            },
            fn () => [],
        ]$definition);

        
Criteria $criteria,
        Search $search,
        ShopContextInterface $context
    ): void {
        $query = $this->combinedConditionQueryBuilder->build(
            $criteriaPart->getConditions(),
            $criteria,
            $context
        );

        $filter = new FilterAggregation($criteriaPart->getName());
        $filter->setFilter($query);

        $search->addAggregation($filter);
    }
}
if ($criteria === null) {
            $criteria = new Criteria();
            $criteria->setOffset(0);
        }

        if ($criteria->getLimit() === null || $criteria->getLimit() < 1) {
            $criteria->setLimit(50);
        }

        if ($repository->getDefinition()->hasAutoIncrement()) {
            $criteria->addSorting(new FieldSorting('autoIncrement', FieldSorting::ASCENDING));
            $criteria->setFilter('increment', new RangeFilter('autoIncrement', [RangeFilter::GTE => 0]));
            $this->autoIncrement = true;
        }

        $this->criteria = $criteria;
        $this->repository = $repository;
        $this->context = clone $context;
    }

    public function getTotal(): int
    {
        $criteria = clone $this->criteria;
        

    public function handle(
        CriteriaPartInterface $criteriaPart,
        Criteria $criteria,
        Search $search,
        ShopContextInterface $context
    ) {
        $aggregation = new ValueCountAggregation('shipping_free_count');
        $aggregation->setField('shippingFree');

        $filterAgg = new FilterAggregation('shipping_free_filter');
        $filterAgg->setFilter(new TermQuery('shippingFree', true));
        $filterAgg->addAggregation($aggregation);

        $search->addAggregation($filterAgg);
    }

    /** * {@inheritdoc} */
    public function hydrate(
        array $elasticResult,
        ProductNumberSearchResult $result,
        

                $aggregation = new TermsAggregation($criteriaPart->getName());
                $aggregation->setField($field);
                $aggregation->addParameter('size', self::AGGREGATION_SIZE);
                break;

            case ProductAttributeFacet::MODE_BOOLEAN_RESULT:
                $count = new ValueCountAggregation($criteriaPart->getName() . '_count');
                $count->setField($field);

                $aggregation = new FilterAggregation($criteriaPart->getName());
                $aggregation->setFilter(new ExistsQuery($field));
                $aggregation->addAggregation($count);
                break;

            case ProductAttributeFacet::MODE_RANGE_RESULT:
                $aggregation = new TermsAggregation($criteriaPart->getName());
                $aggregation->setField($field);
                $aggregation->addParameter('size', self::AGGREGATION_SIZE);
                break;

            default:
                return;
        }

    public function handle(
        CriteriaPartInterface $criteriaPart,
        Criteria $criteria,
        Search $search,
        ShopContextInterface $context
    ) {
        $aggregation = new ValueCountAggregation('has_available_variant_count');
        $aggregation->setField('hasAvailableVariant');

        $filter = new FilterAggregation('has_available_variant_filter');
        $filter->setFilter(new TermQuery('hasAvailableVariant', true));
        $filter->addAggregation($aggregation);

        $search->addAggregation($filter);
    }

    /** * {@inheritdoc} */
    public function hydrate(
        array $elasticResult,
        ProductNumberSearchResult $result,
        
Home | Imprint | This part of the site doesn't use cookies.