public function countTotal($categoryId=null)
    {
        $qb = $this->getQueryBuilder()
            ->select('COUNT(p)');

        if(!is_null($categoryId)){
            $qb->join('p.categories', 'c')
               ->where('c.id = :categoryId')
               ->setParameter('categoryId', $categoryId);
        }
        
        return $qb->getQuery()->getSingleScalarResult();
    }