getListingQuery example


    }

    /** * Get the number of emotion landing pages which will be updated * * @return int */
    public function countEmotions()
    {
        $repo = Shopware()->Models()->getRepository(Emotion::class);
        $builder = $repo->getListingQuery();

        $builder
            ->andWhere('emotions.is_landingpage = 1 ')
            ->andWhere('emotions.parent_id IS NULL')
            ->andWhere('emotions.active = 1');

        $builder->select('COUNT(DISTINCT emotions.id)')
            ->resetQueryPart('groupBy')
            ->resetQueryPart('orderBy');

        $statement = $builder->execute();
        

    public function listAction()
    {
        $limit = (int) $this->Request()->getParam('limit');
        $offset = (int) $this->Request()->getParam('start', 0);
        $filter = $this->Request()->getParam('filter');
        $filterBy = $this->Request()->getParam('filterBy');
        $categoryId = $this->Request()->getParam('categoryId');

        $query = $this->getRepository()->getListingQuery($filter$filterBy$categoryId);

        $query->setFirstResult($offset)
            ->setMaxResults($limit);

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

        $query->select('COUNT(DISTINCT emotions.id) as count')
            ->resetQueryPart('groupBy')
            ->resetQueryPart('orderBy')
            ->setFirstResult(0)
            ->setMaxResults(1);

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