getQueryCount example

default:
                break;
        }

        $builder->addFilter((array) $this->Request()->getParam('filter', []))
            ->addOrderBy((array) $this->Request()->getParam('sort', []));
        $builder->setFirstResult($this->Request()->getParam('start'))
            ->setMaxResults($this->Request()->getParam('limit'));

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

        if (!empty($data) && $name === 'locale') {
            $data = $this->getSnippetsForLocales($data);
        }

        if ($name === 'document') {
            // Translate document type             // The standard $translationComponent->translateDocuments can not be used here since the             // name 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 name
$offset = $request->getParam('start', 0);

        $query = trim($request->getParam('query', ''));
        if ($query !== '') {
            $filter[] = [
                'property' => 'name',
                'value' => $query,
            ];
        }

        $query = $this->getRepository()->getSupplierListQuery($filter$sort$limit$offset);
        $total = $this->get('models')->getQueryCount($query);

        $suppliers = $query->getArrayResult();
        $mediaService = Shopware()->Container()->get(MediaServiceInterface::class);

        foreach ($suppliers as &$supplier) {
            $supplier['description'] = strip_tags((string) $supplier['description']);
            $supplier['image'] = $mediaService->getUrl($supplier['image']);
        }
        unset($supplier);

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

        // If a search-filter is set         if ($this->Request()->get('filter')) {
            // Get the value itself             $filter = $this->Request()->get('filter');
            $filter = $filter[\count($filter) - 1];
            $filterValue = $filter['value'];

            $query = $repository->getBackendPremiumListQuery($start$limit$order$filterValue);
            $totalResult = $this->get('models')->getQueryCount($query);
        } else {
            $query = $repository->getBackendPremiumListQuery($start$limit$order);
            $totalResult = $this->get('models')->getQueryCount($query);
        }

        try {
            $data = $query->getArrayResult();

            $this->View()->assign(['success' => true, 'data' => $data, 'total' => $totalResult]);
        } catch (Exception $e) {
            $this->View()->assign(['success' => false, 'errorMsg' => $e->getMessage()]);
        }
->orWhere('log.ipAddress LIKE ?1')
                ->orWhere('log.key LIKE ?1')
                ->orWhere('log.type LIKE ?1');

            $builder->setParameter(1, '%' . $filter['value'] . '%');
        }
        $builder->addOrderBy($order);

        $builder->setFirstResult($start)->setMaxResults($limit);

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

        $this->View()->assign(['success' => true, 'data' => $result, 'total' => $total]);
    }

    /** * This function is called when the user wants to delete a log. * It only handles the deletion. * * @return void */
    public function deleteLogsAction()
    {

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

        $query = $repository->getTaxQuery(
            $this->Request()->getParam('filter', []),
            $this->Request()->getParam('sort', []),
            $this->Request()->getParam('start'),
            $this->Request()->getParam('limit')
        );

        // Get total result of the query         $total = $this->get('models')->getQueryCount($query);

        // Select all shop as array         $data = $query->getArrayResult();

        // Return the data and total count         $this->View()->assign(['success' => true, 'data' => $data, 'total' => $total]);
    }

    /** * Returns a list of payments. Supports store paging, sorting and filtering over the standard ExtJs store parameters. * Each payment has the following fields: * <code> * [int] id * [string] name * [string] description * [int] position * [int] active * </code>getlocalesaction */

        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 */
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()]);
        }
    }

    
/** * Handles cleaning process and returns the number of deleted media objects */
    private function handleCleanup(SymfonyStyle $io): int
    {
        $em = $this->getContainer()->get(ModelManager::class);

        $query = $em->getRepository(Media::class)->getAlbumMediaQuery(Album::ALBUM_GARBAGE);
        $query->setHydrationMode(AbstractQuery::HYDRATE_OBJECT);

        $count = (int) $em->getQueryCount($query);
        $iterableResult = $query->toIterable();

        $progressBar = $io->createProgressBar($count);

        try {
            foreach ($iterableResult as $key => $media) {
                $em->remove($media);
                if ($key % 100 === 0) {
                    $em->flush();
                    $em->clear();
                }
                
protected $propertyRepository;

    /** * Returns the groups for the sets grids */
    public function getSetsAction()
    {
        $limit = (int) $this->Request()->getParam('limit', 0);
        $offset = (int) $this->Request()->getParam('start', 0);
        $filter = $this->Request()->getParam('filter', []);
        $query = $this->getPropertyRepository()->getSetsQuery($offset$limit$filter);
        $totalCount = $this->getManager()->getQueryCount($query);
        $sets = $query->getArrayResult();

        $this->View()->assign(
            [
                'success' => true,
                'data' => $sets,
                'total' => $totalCount,
            ]
        );
    }

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

        foreach ($data as $key => $category) {
            $data[$key]['text'] = $category['name'];
            $data[$key]['cls'] = 'folder';
            $data[$key]['childrenCount'] = (int) $category['childrenCount'];
            $data[$key]['leaf'] = empty($data[$key]['childrenCount']);
            $data[$key]['allowDrag'] = true;
            if ($preselectedNodes !== null) {
                $data[$key]['checked'] = \in_array($category['id']$preselectedNodes);
            }

            if (empty($node['value'])) {
                $node['value'] = '';
            }
            if (empty($node['factor'])) {
                $node['factor'] = '';
            }
            $nodes[$i] = $node;
            ++$i;
        }

        $totalResult = $this->getModelManager()->getQueryCount($query);
        $this->View()->assign(['success' => true, 'data' => $nodes, 'total' => $totalResult]);
    }

    /** * This method is used to delete one single matrix entry. This data set is addressed through a given ID. * * @return void */
    public function deleteCostsMatrixEntryAction()
    {
        $costsId = $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]);
    }

    /** * Creates new form * * @throws OptimisticLockException * @throws ORMInvalidArgumentException */
'tax' => (float) $product->getTax()->getTax(),
        ];

        $idQuery = $this->getRepository()->getConfiguratorListIdsQuery(
            $productId,
            $this->Request()->getParam('filter'),
            $this->Request()->getParam('sort'),
            $this->Request()->getParam('start'),
            $this->Request()->getParam('limit', 20)
        );

        $total = $this->get('models')->getQueryCount($idQuery);
        $ids = $idQuery->getArrayResult();

        foreach ($ids as $key => $id) {
            $ids[$key] = $id['id'];
        }
        if (empty($ids)) {
            $this->View()->assign([
                'success' => true,
                'data' => [],
                'total' => 0,
            ]);

            

    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()]);
        }
    }

    /** * Returns a JSON string to the view containing the detail information of an Product Feed */
    
$limit = (int) $this->Request()->getParam('limit', 20);
        $offset = (int) $this->Request()->getParam('start', 0);
        $sort = $this->Request()->getParam('sort', $defaultSort);
        $filter = $this->Request()->getParam('filter');
        $filter = $filter[0]['value'];

        // Get access on the customer getRepository()         $query = $this->getRepository()->getOrdersQuery($customerId$filter$sort$limit$offset);

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

        // Returns the customer data         $orders = $query->getArrayResult();

        $this->View()->assign(['success' => true, 'data' => $orders, 'total' => $totalResult]);
    }

    /** * Event listener method which fires when the detail page of a customer is loaded. * Returns an array of grouped order data to display them in a line chart. */
    
Home | Imprint | This part of the site doesn't use cookies.