public function findNews($family, $limit = null)
    {
        $qb = $this->getQueryBuilder()
            ->orderBy('p.highlighted', 'desc')
            ->addOrderBy('p.createdAt', 'desc');

        // filter by family
        if (!is_null($family)) {
            $qb->innerJoin('p.category', 'c')
                ->innerJoin('c.parentCategory', 'pc')
                ->andWhere('pc.family = :family')
                ->setParameter('family', $family);
        }

        if (!is_null($limit)) {
            $qb->setMaxResults($limit);
        }

        return $qb->getQuery()
            ->getResult();
    }
public function findNews($family, $limit = null)
    {
        $qb = $this->getQueryBuilder()
            ->orderBy('p.highlighted', 'desc')
            ->addOrderBy('p.createdAt', 'desc');

        // filter by family
        if (!is_null($family)) {
            $qb->innerJoin('p.category', 'c')
                ->innerJoin('c.parentCategory', 'pc')
                ->andWhere('pc.family = :family')
                ->setParameter('family', $family);
        }

        if (!is_null($limit)) {
            $qb->setMaxResults($limit);
        }

        return $qb->getQuery()
            ->getResult();
    }
public function findNews ( $ family , $ limit = null ) { $ qb = $ this -> getQueryBuilder ( ) -> orderBy ( 'p.highlighted' , 'desc' ) -> addOrderBy ( 'p.createdAt' , 'desc' ) ; // filter by family if ( ! is_null ( $ family ) ) { $ qb -> innerJoin ( 'p.category' , 'c' ) -> innerJoin ( 'c.parentCategory' , 'pc' ) -> andWhere ( 'pc.family = :family' ) -> setParameter ( 'family' , $ family ) ; } if ( ! is_null ( $ limit ) ) { $ qb -> setMaxResults ( $ limit ) ; } return $ qb -> getQuery ( ) -> getResult ( ) ; }
Find new products

@param Family|null $family
@param int|null    $limit

@return ArrayCollection
Find new products