getSortingHandler example


    private function fetchCustomers(Criteria $criteria, QueryBuilder $query)
    {
        if ($criteria->getOffset() !== null) {
            $query->setFirstResult($criteria->getOffset());
        }
        if ($criteria->getLimit() !== null) {
            $query->setMaxResults($criteria->getLimit());
        }

        foreach ($criteria->getSortings() as $sorting) {
            $handler = $this->handlerRegistry->getSortingHandler($sorting);
            $handler->handle($sorting$query);
        }

        $query->addSelect('customer.id, customer.customernumber, customer.email');

        return $query->execute()->fetchAll(PDO::FETCH_ASSOC);
    }

    private function fetchTotal(QueryBuilder $query)
    {
        $query->select('COUNT(DISTINCT customer.id)');
        
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');
    }

    /** * @throws Exception * * @return SortingHandlerInterface */
    private function getSortingHandler(SortingInterface $sorting)
    {
Home | Imprint | This part of the site doesn't use cookies.