generateCondition example


    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');
    }

    
$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);

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