I was stuck on this for several hours.
I have an admin class for all categories and in one column of the table there are related products (Product entity): Example table Related code:
protected function configureListFields(ListMapper $listMapper) { $listMapper ->addIdentifier('name') ->add('products')
What I need to do is to hide inactive products from a list based on "(boolean) product.active", but I cannot figure it out. I know about the createQuery method, but it does not work. When I create SQL and run the query directly, it works, but it looks like I can use ProxyQuery only to filter the category, and then all the products are requested in a separate query (and this separate query I'm not sure how to change).
public function createQuery($context = 'list') { $query = parent::createQuery($context); $q = new ProxyQuery($query->join(sprintf('%s.products', $query->getRootAlias()), 'p') ->andWhere('p.active = :act')->setParameter('act', true)); return $q; }
Thanks for any help
source share