getConditionHandler example

$query->addState($condition->getName());

        $this->addConditions($condition$query$context);
    }

    private function addConditions(
        CombinedCondition $condition,
        QueryBuilder $query,
        ShopContextInterface $context
    ): void {
        foreach ($condition->getConditions() as $innerCondition) {
            $handler = $this->getConditionHandler($innerCondition);
            $handler->generateCondition($innerCondition$query$context);
        }
    }

    /** * @throws RuntimeException */
    private function getConditionHandler(ConditionInterface $condition): ConditionHandlerInterface
    {
        // Initialize the condition handler collection service         $this->container->get(QueryBuilderFactory::class);

        
/** * @return QueryBuilder */
    private function buildQuery(Criteria $criteria)
    {
        $query = new QueryBuilder($this->connection);

        $query->from('s_customer_search_index', 'customer');
        $query->leftJoin('customer', 's_user_attributes', 'customerAttribute', 'customerAttribute.userID = customer.id');

        foreach ($criteria->getConditions() as $condition) {
            $handler = $this->handlerRegistry->getConditionHandler($condition);
            $handler->handle($condition$query);
        }

        return $query;
    }

    /** * @return array[] */
    private function fetchCustomers(Criteria $criteria, QueryBuilder $query)
    {
        
/** * {@inheritdoc} */
    public function createQueryBuilder()
    {
        return new QueryBuilder($this->connection);
    }

    private function addConditions(Criteria $criteria, QueryBuilder $query, ShopContextInterface $context)
    {
        foreach ($criteria->getConditions() as $condition) {
            $handler = $this->getConditionHandler($condition);
            $handler->generateCondition($condition$query$context);
        }
    }

    private function addSorting(Criteria $criteria, QueryBuilder $query, ShopContextInterface $context)
    {
        foreach ($criteria->getSortings() as $sorting) {
            $handler = $this->getSortingHandler($sorting);
            $handler->generateSorting($sorting$query$context);
        }
        $query->addOrderBy('variant.id', 'ASC');
    }
Home | Imprint | This part of the site doesn't use cookies.