i'm using sonata admin for managing entities in my symfony application. the entities have some many to many properties, and i want to administrate them in sonata. therefore i added this to the entity:
/**
* @ORM\ManyToMany(targetEntity="Product", inversedBy="farmer", cascade={"persist"})
* @ORM\JoinTable(name="farmerproduct",
* joinColumns={
* @ORM\JoinColumn(name="farmer_id", referencedColumnName="id")
* },
* inverseJoinColumns={
* @ORM\JoinColumn(name="product_id", referencedColumnName="id")
* }
* )
*/
private $products;
The problem now is that in my application, I'm fetching lots of these farmers (the entity) and this ends up in a PHP Fatal error: Allowed memory size of 134217728 bytes exhausted
The reason is, I'm sending the results to the web application through JSON.
How can I use the products only in sonata admin only? I have already programmed some lazy loading style fetching of the products in a next step. So i don't need it in my webapplication.
Any ideas?