public function getBrands($category, $limit = null)
    {
        $qb = $this->getQueryBuilder()
            ->select('DISTINCT b.id, b.name')
            ->innerJoin('c.products', 'p')
            ->innerJoin('p.brand', 'b')
            ->where('p.active = TRUE')
            ->andWhere('b.available = TRUE');

        if ($category->getFamily()) {
            // this is a category
            $qb->andWhere('c.parentCategory = :category')
                ->setParameter('category', $category);
        } else {
            // this is a subcategory
            $qb->andWhere('c = :category')
                ->setParameter('category', $category);
        }

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

        return $qb->getQuery()
            ->getResult();
    }
public function getBrands($category, $limit = null)
    {
        $qb = $this->getQueryBuilder()
            ->select('DISTINCT b.id, b.name')
            ->innerJoin('c.products', 'p')
            ->innerJoin('p.brand', 'b')
            ->where('p.active = TRUE')
            ->andWhere('b.available = TRUE');

        if ($category->getFamily()) {
            // this is a category
            $qb->andWhere('c.parentCategory = :category')
                ->setParameter('category', $category);
        } else {
            // this is a subcategory
            $qb->andWhere('c = :category')
                ->setParameter('category', $category);
        }

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

        return $qb->getQuery()
            ->getResult();
    }
public function getBrands ( $ category , $ limit = null ) { $ qb = $ this -> getQueryBuilder ( ) -> select ( 'DISTINCT b.id, b.name' ) -> innerJoin ( 'c.products' , 'p' ) -> innerJoin ( 'p.brand' , 'b' ) -> where ( 'p.active = TRUE' ) -> andWhere ( 'b.available = TRUE' ) ; if ( $ category -> getFamily ( ) ) { // this is a category $ qb -> andWhere ( 'c.parentCategory = :category' ) -> setParameter ( 'category' , $ category ) ; } else { // this is a subcategory $ qb -> andWhere ( 'c = :category' ) -> setParameter ( 'category' , $ category ) ; } if ( ! is_null ( $ limit ) ) { $ qb -> setMaxResults ( $ limit ) ; } return $ qb -> getQuery ( ) -> getResult ( ) ; }
Get brands from their products relationship

@param Category     $category
@param integer|null $limit

@return ArrayCollection
Get brands from their products relationship