I have a problem with GroupBy.
I have entity with categories and entity with products. I want to get all the products grouped by category(id).
public function getAll() { $qb = $this->createQueryBuilder('p'); $qb->leftJoin('p.categories', 'category'); $qb->where('p.enabled = true'); $qb->andWhere('p.visible = true'); $qb->andWhere('p.quantity >= 1'); $qb->groupBy('category.id'); return $qb->getQuery()->getResult(); } But this returns just few records(I think 1 from each category).
How can I get all products grouped in categories?
Thanks