Sonata\ProductBundle\Entity\ProductManager::findProductForCategory PHP Method

findProductForCategory() public method

Returns partial product example (only to get its class) from $category.
public findProductForCategory ( Sonata\ClassificationBundle\Model\CategoryInterface $category ) : Sonata\Component\Product\ProductInterface | null
$category Sonata\ClassificationBundle\Model\CategoryInterface
return Sonata\Component\Product\ProductInterface | null
    public function findProductForCategory(CategoryInterface $category)
    {
        return $this->getCategoryProductsQueryBuilder($category)->select('partial p.{id}')->setMaxResults(1)->getQuery()->getOneOrNullResult();
    }