How can I get access to related entities with Symfony doctrine?

I try to find all documents that are related to my product:

public function findDocumentsRelatedToProduct($id) {
        return $this->createQueryBuilder('products')
                        ->leftJoin('products.documents', 'pd')
                        ->where(" = :id")
                        ->setParameter(':id', $id)


$products = $this->em->getRepository('AppEntityProducts')->findDocumentsRelatedToProduct($id);

foreach ($products as $key => $value) {

But I get the error message:

Attempted to call an undefined method named "getId" of class "DoctrineORMPersistentCollection".

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *