getListQuery example


    protected function getList($offset$limit$sort = []$filter = [], array $wholeParams = [])
    {
        $builder = $this->getListQuery();
        $builder->setFirstResult($offset)
            ->setMaxResults($limit);

        $filter = $this->getFilterConditions(
            $filter,
            $this->model,
            $this->alias,
            $this->filterFields
        );

        $sort = $this->getSortConditions(
            
// get all blog category ids         $blogCategoryIds = [];
        foreach ($blogCategories as $blogCategory) {
            $blogCategoryIds[] = $blogCategory['id'];
        }

        if ($context === null) {
            $context = $this->contextService->getShopContext();
        }

        $blogArticlesQuery = $this->modelManager->getRepository(Blog::class)
            ->getListQuery($blogCategoryIds$offset$limit);
        $blogArticlesQuery->setHydrationMode(AbstractQuery::HYDRATE_ARRAY);
        $blogArticles = $blogArticlesQuery->getArrayResult();

        $routerBlogTemplate = $this->config->get('routerBlogTemplate');
        foreach ($blogArticles as $blogArticle) {
            $blogTranslation = $this->translationComponent->readWithFallback(
                $context->getShop()->getId(),
                $context->getShop()->getFallbackId(),
                'blog',
                $blogArticle['id'],
                false
            );
$this->addAclPermission('deletePayment', 'delete', "You're not allowed to delete the payment.");
    }

    /** * Main-Method to get all payments and its countries and subshops * The data is additionally formatted, so additional-information are also given */
    public function getPaymentsAction()
    {
        $this->repository = $this->get('models')->getRepository(Payment::class);

        $query = $this->repository->getListQuery(null, [
            ['property' => 'payment.active', 'direction' => 'DESC'],
            ['property' => 'payment.position'],
        ]);
        $results = $query->getArrayResult();

        // Translate payments         // The standard $translationComponent->translatePayments can not be used here since the         // description may not be overridden. The field is edible and if the translation is         // shown in the edit field, there is a high chance of a user saving the translation as description.         $translator = $this->get(Shopware_Components_Translation::class)->getObjectTranslator('config_payment');
        $results = array_map(function D$payment) use ($translator) {
            
/** * {@inheritdoc} */
    protected function getListQuery()
    {
        $customerId = (int) $this->Request()->get('customerId');

        if (!$customerId) {
            throw new \RuntimeException('You have to provide a valid customerId.');
        }

        $query = parent::getListQuery();
        $query = $this->addAssociations($query);
        $query->andWhere('IDENTITY(address.customer) = :customerId')
            ->setParameter('customerId', $customerId);

        return $query;
    }

    /** * {@inheritdoc} */
    protected function getQueryPaginator(QueryBuilder $builder$hydrationMode = AbstractQuery::HYDRATE_ARRAY)
    {

        // if id is provided return a single form instead of a collection         if ($id = $this->Request()->getParam('id')) {
            return $this->getSingleForm($id);
        }

        $offset = $this->Request()->getParam('start');
        $limit = $this->Request()->getParam('limit', 20);
        $filter = $this->prefixProperties($this->Request()->getParam('filter', []), 'form');
        $order = $this->prefixProperties($this->Request()->getParam('sort', []), 'form');

        $query = $this->getRepository()->getListQuery($filter$order$offset$limit);

        // returns the total count of the query         $totalResult = $this->getManager()->getQueryCount($query);

        $forms = $query->getArrayResult();

        foreach ($forms as &$form) {
            $form['shopIds'] = $this->explodeShopIds($form['shopIds']);
        }

        $this->View()->assign(['success' => true, 'data' => $forms, 'total' => $totalResult]);
    }
$node = (int) $this->Request()->getParam('node');
        $node = $node > 0 ? $node : null;
        $sort = $this->Request()->getParam('sort', []);
        $filter = $this->Request()->getParam('filter', []);
        $filter[] = [
            'property' => 'mainId',
            'value' => $node,
        ];

        $repository = $this->get('models')->getRepository(Shop::class);

        $query = $repository->getListQuery($filter$sort);

        $data = $query->getArrayResult();
        $this->View()->assign([
            'success' => true, 'data' => $data, 'total' => \count($data),
        ]);
    }

    /** * Assign stored translation data. */
    public function readTranslationAction()
    {
$condition['expression'] = '>=';
                    break;
            }
        }

        $repository = $this->container->get(CustomerRepository::class);

        $result = $repository->search($criteria);

        $ids = array_column($result->getData(), 'id');

        $query = $this->getListQuery();
        $query->where('customer.id IN (:ids)');
        $query->setParameter('ids', $ids, Connection::PARAM_INT_ARRAY);

        $data = $query->getQuery()->getArrayResult();

        $sortedData = [];
        foreach ($ids as $id) {
            foreach ($data as $key => $row) {
                if ($row['id'] == $id) {
                    $sortedData[] = $row;
                    unset($data[$key]);
                    

    public function getListAction()
    {
        try {
            $limit = (int) $this->Request()->getParam('limit');
            $offset = (int) $this->Request()->getParam('start');

            // Order data             $order = (array) $this->Request()->getParam('sort', []);

            $repository = $this->get('models')->getRepository(Partner::class);
            $dataQuery = $repository->getListQuery($order$offset$limit);

            $totalCount = $this->get('models')->getQueryCount($dataQuery);
            $data = $dataQuery->getArrayResult();

            $this->View()->assign(['success' => true, 'data' => $data, 'totalCount' => $totalCount]);
        } catch (Exception $e) {
            $this->View()->assign(['success' => false, 'errorMsg' => $e->getMessage()]);
        }
    }

    /** * Returns a JSON string for the statistic overview * * @return void */

        /** @var array $filter */
        $filter = $this->Request()->getParam('filter', []);
        $node = (int) $this->Request()->getParam('node');
        $preselectedNodes = $this->Request()->getParam('preselected');

        if (empty($filter)) {
            $node = !empty($node) ? $node : 1;
            $filter[] = ['property' => 'c.parentId', 'value' => $node];
        }

        $query = $this->get('models')->getRepository(Category::class)->getListQuery(
            $filter,
            $this->Request()->getParam('sort', []),
            $this->Request()->getParam('limit'),
            $this->Request()->getParam('start'),
            false
        );

        $count = $this->get('models')->getQueryCount($query);

        $data = $query->getArrayResult();

        

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

        /** @var Query<array<string, mixed>> $query */
        $query = $this->getListQuery($offset$limit$criteria$orderBy)->getQuery();
        $query->setHydrationMode(self::HYDRATE_ARRAY);
        $paginator = $this->getManager()->createPaginator($query);

        $translations = iterator_to_array($paginator);

        foreach ($translations as &$translation) {
            unset($translation['id']);
            $translation['data'] = $this->getTranslationComponent()->unFilterData(
                'article',
                $translation['data']
            );
        }
/** * @param int $offset * @param int $limit * * @return array */
    public function getList($offset = 0, $limit = 25, array $criteria = [], array $orderBy = [])
    {
        $this->checkPrivilege('read');

        $query = $this->getRepository()->getListQuery($criteria$orderBy$limit$offset);
        $query->setHydrationMode(self::HYDRATE_ARRAY);

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

        // Returns the total count of the query         $totalResult = $paginator->count();

        // Returns the manufacturer data         $manufacturers = iterator_to_array($paginator);

        return ['data' => $manufacturers, 'total' => $totalResult];
    }
return $list;
        }

        // assign shops over additional query to improve performance         $shops = $this->getShops($shopIds);

        return $this->assignShops($list$shops);
    }

    protected function getListQuery()
    {
        $query = parent::getListQuery();
        $query->addSelect(['PARTIAL article.{id, name}']);
        $query->leftJoin('vote.article', 'article');

        return $query;
    }

    protected function getDetailQuery($id)
    {
        $query = parent::getDetailQuery($id);
        $query->addSelect(['PARTIAL article.{id, name}']);
        $query->addSelect('shop');
        

    protected $shopRepository;

    /** * Returns a JSON string to the view containing all Product Feeds */
    public function getFeedsAction()
    {
        try {
            $repository = $this->get('models')->getRepository(ProductFeed::class);
            $dataQuery = $repository->getListQuery(
                $this->Request()->getParam('sort', []),
                $this->Request()->getParam('start'),
                $this->Request()->getParam('limit')
            );

            $totalCount = $this->get('models')->getQueryCount($dataQuery);
            $feeds = $dataQuery->getArrayResult();

            $this->View()->assign(['success' => true, 'data' => $feeds, 'totalCount' => $totalCount]);
        } catch (Exception $e) {
            $this->View()->assign(['success' => false, 'errorMsg' => $e->getMessage()]);
        }
/** * @param int $offset * @param int $limit * * @return array */
    public function getList($offset = 0, $limit = 25, array $criteria = [], array $orderBy = [])
    {
        $this->checkPrivilege('read');

        $query = $this->getRepository()->getListQuery($criteria$orderBy$limit$offset);
        $query->setHydrationMode($this->resultMode);

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

        // Returns the total count of the query         $totalResult = $paginator->count();

        // Returns the category data         $categories = iterator_to_array($paginator);

        return ['data' => $categories, 'total' => $totalResult];
    }
$conditions[] = $condition;
        }

        return $conditions;
    }

    /** * {@inheritdoc} */
    protected function getListQuery(): QueryBuilder
    {
        $builder = parent::getListQuery();

        $builder->leftJoin('mailLog.order', self::JOIN_ALIAS_ORDER)
            ->leftJoin('mailLog.recipients', self::JOIN_ALIAS_RECIPIENTS)
            ->addSelect([self::JOIN_ALIAS_ORDER, self::JOIN_ALIAS_RECIPIENTS]);

        return $builder;
    }

    /** * {@inheritdoc} */
    
Home | Imprint | This part of the site doesn't use cookies.