getCustomerGroupIds example

public function handle(ConditionInterface $condition, QueryBuilder $query)
    {
        $this->addCondition($condition$query);
    }

    private function addCondition(IsInCustomerGroupCondition $condition, QueryBuilder $query): void
    {
        $query->andWhere('customer.customer_group_id IN (:IsInCustomerGroupCondition)');
        $query->setParameter(
            ':IsInCustomerGroupCondition',
            $condition->getCustomerGroupIds(),
            Connection::PARAM_INT_ARRAY
        );
    }
}
$query->leftJoin(
            'product',
            's_articles_avoid_customergroups',
            'avoidCustomerGroup',
            'avoidCustomerGroup.articleID = product.id AND avoidCustomerGroup.customerGroupId IN (' . $key . ')'
        );

        $query->setParameter(
            $key,
            $condition->getCustomerGroupIds(),
            Connection::PARAM_INT_ARRAY
        );

        $query->andWhere('avoidCustomerGroup.articleID IS NULL');
    }
}
Criteria $criteria,
        Search $search,
        ShopContextInterface $context
    ) {
        $search->addPostFilter($this->getQuery($criteriaPart));
    }

    private function getQuery(CustomerGroupCondition $criteriaPart): BoolQuery
    {
        $filter = new BoolQuery();
        $filter->add(
            new TermsQuery('blockedCustomerGroupIds', $criteriaPart->getCustomerGroupIds()),
            BoolQuery::MUST_NOT
        );

        return $filter;
    }
}
public function handle(ConditionInterface $condition, QueryBuilder $query): void
    {
        $this->addCondition($condition$query);
    }

    private function addCondition(IsNotInCustomerGroupCondition $condition, QueryBuilder $query): void
    {
        $query->andWhere('customer.customer_group_id NOT IN (:IsNotInCustomerGroupCondition)');
        $query->setParameter(
            ':IsNotInCustomerGroupCondition',
            $condition->getCustomerGroupIds(),
            Connection::PARAM_INT_ARRAY
        );
    }
}
Home | Imprint | This part of the site doesn't use cookies.