protected function getCategoryProductsQueryBuilder(CategoryInterface $category = null)
    {
        $queryBuilder = $this->getRepository()->createQueryBuilder('p')
            ->leftJoin('p.image', 'i')
            ->leftJoin('p.gallery', 'g');

        if ($category) {
            $queryBuilder
                ->leftJoin('p.productCategories', 'pc')
                ->andWhere('pc.category = :categoryId')
                ->setParameter('categoryId', $category->getId());
        }

        return $queryBuilder;
    }
protected function getCategoryProductsQueryBuilder(CategoryInterface $category = null)
    {
        $queryBuilder = $this->getRepository()->createQueryBuilder('p')
            ->leftJoin('p.image', 'i')
            ->leftJoin('p.gallery', 'g');

        if ($category) {
            $queryBuilder
                ->leftJoin('p.productCategories', 'pc')
                ->andWhere('pc.category = :categoryId')
                ->setParameter('categoryId', $category->getId());
        }

        return $queryBuilder;
    }
protected function getCategoryProductsQueryBuilder ( CategoryInterface $ category = null ) { $ queryBuilder = $ this -> getRepository ( ) -> createQueryBuilder ( 'p' ) -> leftJoin ( 'p.image' , 'i' ) -> leftJoin ( 'p.gallery' , 'g' ) ; if ( $ category ) { $ queryBuilder -> leftJoin ( 'p.productCategories' , 'pc' ) -> andWhere ( 'pc.category = :categoryId' ) -> setParameter ( 'categoryId' , $ category -> getId ( ) ) ; } return $ queryBuilder ; }
Returns QueryBuilder for products.

@param CategoryInterface $category

@return QueryBuilder
Returns QueryBuilder for products .