buildGroupBy example

public function handlePostFilter(
        CriteriaPartInterface $criteriaPart,
        Criteria $criteria,
        Search $search,
        ShopContextInterface $context
    ) {
        $this->handle($criteria$search);
    }

    private function handle(Criteria $criteria, Search $search): void
    {
        $groupBy = $this->buildGroupBy($criteria);

        if ($groupBy) {
            $search->addPostFilter(new TermQuery($groupBy, true));

            return;
        }

        $search->addPostFilter(
            new TermQuery('hasStock', true)
        );
    }

    
public function handlePostFilter(
        CriteriaPartInterface $criteriaPart,
        Criteria $criteria,
        Search $search,
        ShopContextInterface $context
    ) {
        $this->handle($criteriaPart$criteria$search);
    }

    private function handle(VariantCondition $criteriaPart, Criteria $criteria, Search $search): void
    {
        $groupBy = $this->buildGroupBy($criteria);

        if ($groupBy) {
            $search->addPostFilter(new TermQuery($groupBy, true));

            $search->addPostFilter(
                new TermsQuery(
                    'filterConfiguration.options.id',
                    $criteriaPart->getOptionIds()
                )
            );

            
Home | Imprint | This part of the site doesn't use cookies.