I have two entities - Category and Item. Category can have multiple Items. I've set up sonata admin for a Category and in list mapper I have "->add('items'). I also have datagridFilters for Category where I also have "->add('items'). Everything works well (I get a list of Categories and for each Category I get a comma separated list of Items. If I use filtering by Item, I find Category that contains that Item and it shows other Items in that Category as it is supposed to. However, if I add in configureQuery relation to items, and use filtering by Item as previously, all other Items related to Category are filtered out as well:
protected function configureQuery(ProxyQueryInterface $query): ProxyQueryInterface
{
$query = parent::configureQuery($query);
$rootAlias = current($query->getRootAliases());
$query
->addSelect('i')
->leftJoin($rootAlias . '.items', 'i')
;
return $query;
}
Is there any solution to overcome this behavior?
I've tried removing configureQuery and enabling it again and this is the cause of the issue. However, I need it so queries would be more efficient.