addOrderBy example

'productFeed.id as id',
                'productFeed.name as name',
                'productFeed.active as active',
                'productFeed.fileName as fileName',
                'productFeed.countArticles as countArticles',
                'productFeed.hash as hash',
                'productFeed.lastExport as lastExport',
            ]
        );
        $builder->from(ProductFeed::class, 'productFeed');
        if (!empty($orderBy)) {
            $builder->addOrderBy($orderBy);
        }

        return $builder;
    }

    /** * Returns an instance of the \Doctrine\ORM\Query object which select a list of active * product feeds. * * @return Query<ProductFeed> */
    

    public function getList($offset = 0, $limit = 25, array $criteria = [], array $orderBy = [])
    {
        $this->checkPrivilege('read', 'usermanager');

        $builder = $this->getRepository()->createQueryBuilder('user')
            ->join('user.role', 'role')
            ->addSelect(['attribute'])
            ->leftJoin('user.attribute', 'attribute')
            ->addFilter($criteria)
            ->addOrderBy($orderBy)
            ->setFirstResult($offset)
            ->setMaxResults($limit);

        /** @var Query<UserModel|array<string, mixed>> $query */
        $query = $builder->getQuery();
        $query->setHydrationMode($this->getResultMode());

        $paginator = $this->getManager()->createPaginator($query);

        $users = iterator_to_array($paginator);

        


    public function setCriteria(Criteria $criteria)
    {
        $this->criteria = $criteria;
    }

    private function addSorting(PriceSorting $sorting, QueryBuilder $query, ShopContextInterface $context): void
    {
        $this->listingPriceSwitcher->joinPrice($query$this->criteria, $context);

        $query->addOrderBy('listing_price.cheapest_price', $sorting->getDirection());
    }
}
/** * Function to get all active payment-means and the ruleSets */
    public function getPaymentsAction()
    {
        try {
            $builder = $this->get('models')->createQueryBuilder();
            $builder->select(['payment', 'ruleSets'])
                    ->from('Shopware\Models\Payment\Payment', 'payment');
            $builder->leftJoin('payment.ruleSets', 'ruleSets');
            $builder->orderBy('payment.active', 'desc');
            $builder->addOrderBy('payment.id');

            $result = $builder->getQuery()->getArrayResult();
            $total = $this->get('models')->getQueryCount($builder->getQuery());

            // Translate the payment methods             $translationComponent = $this->get(Shopware_Components_Translation::class);
            $result = $translationComponent->translatePaymentMethods($result);

            $this->View()->assign(['success' => true, 'data' => $result, 'total' => $total]);
        } catch (Exception $e) {
            $this->View()->assign(['success' => false, 'errorMsg' => $e->getMessage()]);
        }
$query->addSelect(['seo_path_info', 'path_info']);

        $query->from('seo_url');
        $query->andWhere('seo_url.is_canonical = 1');
        $query->andWhere('seo_url.path_info IN (:pathInfo)');
        $query->andWhere('seo_url.language_id = :languageId');
        $query->andWhere('seo_url.sales_channel_id = :salesChannelId OR seo_url.sales_channel_id IS NULL');
        $query->andWhere('is_deleted = 0');
        $query->setParameter('pathInfo', $mapping, ArrayParameterType::STRING);
        $query->setParameter('languageId', Uuid::fromHexToBytes($context->getContext()->getLanguageId()));
        $query->setParameter('salesChannelId', Uuid::fromHexToBytes($context->getSalesChannelId()));
        $query->addOrderBy('seo_url.sales_channel_id');

        $seoUrls = $query->executeQuery()->fetchAllAssociative();
        foreach ($seoUrls as $seoUrl) {
            $seoPathInfo = trim((string) $seoUrl['seo_path_info']);
            if ($seoPathInfo === '') {
                continue;
            }
            $key = self::DOMAIN_PLACEHOLDER . $seoUrl['path_info'] . '#';
            $mapping[$key] = $seoPathInfo;
        }

        


        return $this->sqlToRedis($input$output);
    }

    protected function createIterator(): LastIdQuery
    {
        $query = $this->connection->createQueryBuilder();
        $query->addSelect(['cart.auto_increment', 'cart.token']);
        $query->from('cart');
        $query->andWhere('cart.auto_increment > :lastId');
        $query->addOrderBy('cart.auto_increment');
        $query->setMaxResults(50);
        $query->setParameter('lastId', 0);

        return new LastIdQuery($query);
    }

    private function redisToSql(InputInterface $input, OutputInterface $output): int
    {
        if ($this->redis === null) {
            throw new \RuntimeException('%shopware.cart.redis_url% is not configured and no url provided.');
        }

        
self::PRODUCT,
            's_articles_translations',
            self::TRANSLATION,
            $query->expr()->andX(
                $query->expr()->eq(self::TRANSLATION . '.articleID', self::PRODUCT . '.id'),
                $query->expr()->eq(self::TRANSLATION . '.languageID', $context->getShop()->getId()),
                $query->expr()->isNotNull(self::TRANSLATION_NAME),
                $query->expr()->neq(self::TRANSLATION_NAME, $query->expr()->literal(''))
            )
        );

        $query->addOrderBy(
            self::exprIf(
                $query->expr()->isNull(self::TRANSLATION_NAME),
                self::PRODUCT . '.name',
                self::TRANSLATION_NAME
            ),
            $sorting->getDirection()
        );
    }
}

    public function getIterator()
    {
        $query = $this->entityManager->getConnection()->createQueryBuilder();

        $query = $query
            ->select(['products.id', 'products.ordernumber'])
            ->from('s_articles_details', 'products')
            ->andWhere('products.id > :lastId')
            ->setParameter(':lastId', 0)
            ->addOrderBy('products.id')
            ->setMaxResults(50);

        return new LastIdQuery($query);
    }

    /** * {@inheritdoc} */
    public function getMapping()
    {
        return [
            
'status.id as id',
            'status.name as name',
        ]);
        $builder->from(Status::class, 'status')
            ->where('status.group = ?1')
            ->setParameter(1, 'payment');

        if ($filter !== null) {
            $builder->addFilter($filter);
        }
        if ($order !== null) {
            $builder->addOrderBy($order);
        } else {
            $builder->orderBy('status.position', 'ASC');
        }

        return $builder;
    }

    /** * Returns a query-object for all known order statuses * * @param array|null $filter * @param string|null $order * @param int|null $offset * @param int|null $limit * * @return Query<Status> */
public function completeOptionValues($optionName, CompletionContext $context)
    {
        if ($optionName === 'shopId') {
            $queryBuilder = $this->modelManager->getRepository(ShopModel::class)->createQueryBuilder('shop');

            if (is_numeric($context->getCurrentWord())) {
                $queryBuilder->andWhere($queryBuilder->expr()->like('shop.id', ':id'))
                    ->setParameter('id', addcslashes($context->getCurrentWord(), '%_') . '%');
            }

            $result = $queryBuilder->select(['shop.id'])
                ->addOrderBy($queryBuilder->expr()->asc('shop.id'))
                ->getQuery()
                ->getArrayResult();

            return array_column($result, 'id');
        }

        return [];
    }

    /** * {@inheritdoc} */

        $ids = array_unique($ids);

        $query = $this->connection->createQueryBuilder();

        $query->addSelect($this->fieldHelper->getVoteFields());

        $query->from('s_articles_vote', 'vote')
            ->where('vote.articleID IN (:ids)')
            ->andWhere('vote.active = 1')
            ->orderBy('vote.articleID', 'DESC')
            ->addOrderBy('vote.datum', 'DESC')
            ->setParameter(':ids', $ids, Connection::PARAM_INT_ARRAY);

        if ($this->config->get('displayOnlySubShopVotes')) {
            $query->andWhere('(vote.shop_id = :shopId OR vote.shop_id IS NULL)');
            $query->setParameter(':shopId', $context->getShop()->getId());
        }

        $data = $query->execute()->fetchAll(PDO::FETCH_ASSOC);

        $votes = [];
        foreach ($data as $row) {
            
if ($this->auth->checkAuth() === null) {
            throw new Enlight_Controller_Exception('Unauthorized', 401);
        }

        $menu = $this->get('models')->getRepository(Menu::class);
        $nodes = $menu->createQueryBuilder('m')
            ->select('m')
            ->leftJoin('m.plugin', 'p')
            ->where('m.active = 1')
            ->andWhere('m.pluginId IS NULL OR p.active = 1')
            ->orderBy('m.parentId', 'ASC')
            ->addOrderBy('m.position', 'ASC')
            ->addOrderBy('m.id', 'ASC')
            ->getQuery()
            ->getArrayResult();

        $menuItems = $this->buildTree($nodes);
        $this->View()->assign('menu', $menuItems);
    }

    /** * Returns if the first run wizard should be loaded in the current backend instance * * @param stdClass $identity */
'p.description as description',
                'p.position as position',
                'p.active as active',
            ]
        );
        $builder->where('p.active = 1');

        if ($filter !== null) {
            $builder->addFilter($filter);
        }
        if ($order !== null) {
            $builder->addOrderBy($order);
        }

        return $builder;
    }

    /** * Returns a query-object for all payments * * @param array|null $filter * @param string|array|null $order * @param int|null $offset * @param int|null $limit * * @return Query<Payment> */
$builder->from(Country::class, 'countries')
            ->leftJoin('countries.area', 'area');

        if (\is_array($filter) && $filter[0]['property'] === 'areaId') {
            $builder->where('area.id = :areaId');
            $builder->setParameter('areaId', $filter[0]['value']);
        } elseif ($filter !== null) {
            $builder->addFilter($filter);
        }

        if ($order !== null) {
            $builder->addOrderBy($order);
        }

        return $builder;
    }

    /** * @param array|null $filter * @param string|array|OrderBy|null $order * * @return QueryBuilder */
    
'c.active as active',
            'c.name as name',
            'c.position as position',
            'c.parentId as parentId',
        ]);

        $builder = $this->addChildrenCountSelect($builder);
        if (!empty($filterBy)) {
            $builder->addFilter($filterBy);
        }

        $builder->addOrderBy('c.parentId');
        $builder->addOrderBy('c.position');
        if (!empty($orderBy)) {
            $builder->addOrderBy($orderBy);
        }

        if ($offset !== null && $limit !== null) {
            $builder->setFirstResult($offset)
                ->setMaxResults($limit);
        }

        return $builder;
    }
Home | Imprint | This part of the site doesn't use cookies.