I'm using OroCRM 2.6.19, and for some reason, when I go to page /account
, my datagrid is duplicating some rows:
As you can see in the image above, Oro counts one record, but shows 2 rows, with the same ID.
I tried to add distinct flag through EventListener, with onBuildAfter method, but it did not work:
public function onBuildAfter(BuildAfter $event)
{
$datagrid = $event->getDatagrid();
$config = $datagrid->getConfig();
$query = $config->getOrmQuery();
$query->setDistinct();
}
My services.yml:
services:
my_company_account.event_listener.datagrid.set_distinct_to_account_grid:
class: Company\Bundle\CompanyAccountBundle\EventListener\Datagrid\SetDistinctToAccountGrid
arguments:
- "@oro_security.token_accessor"
tags:
- { name: kernel.event_listener, event: oro_datagrid.datagrid.build.after.accounts-grid, method: onBuildAfter }
How can I show only one record? If I'm implementing the wrong event, can you help me implement the right one?
Thanks a lot!
After a lot of testing and a bit of luck, I found that, for some reason, the Contact associated with the Account had two primary phones in the database. Then, due to the join made to build the datagrid, the results ended up appearing duplicated.
Anyway, thanks, guys!