Forums

Covering OroCRM topics, including community updates and company announcements.  Subscribe

This topic contains 1 reply, has 2 voices, and was last updated by  dkrushelnytskyi@magecore.com 2 months, 3 weeks ago.

  • Creator
    Topic
  • #37103

    oro6
    Participant

    Hello,

    Lets say I have an entity Customer which has a ManyToMany relation to entity Adress. These get fetched via EAGER in Doctrine, so if I dump the entity, it already includes all the addresses.

    How can I show one field of the first address in the datagrid without doing an extra join over the address table? Reason: This gets extremely slow when there are a lot of entries.

    I tried to get the entity in a BuildAfterListener but this gives no results … any hints?

Viewing 1 replies (of 1 total)
  • Author
    Replies
  • #37848

    Hello,

    Platform does not have functionality to simple show many to many relation in grid column,
    but has example which may to help implement it for your case.

    Platform has bundle TagBundle. Tag entity has “many to many” relation with other entities and in the TagBundle there is implemented solution to show tags in the grids (For example, account, contact girds).

    May be this example will help you to solve issue.

    How it works.

    TagBundle has Oro\Bundle\TagBundle\Grid\TagsExtension with methods
    – processConfigs modifies grids definition to add the column “tags” in grids.
    https://github.com/oroinc/platform/blob/master/src/Oro/Bundle/TagBundle/Grid/TagsExtension.php#L110

    – visitResult adds tags data in rows which should be show on the page.
    https://github.com/oroinc/platform/blob/master/src/Oro/Bundle/TagBundle/Grid/TagsExtension.php#L207

    Loading data for grid is executed in Oro\Bundle\DataGridBundle\Datagrid\Datagrid by method getData.

    https://github.com/oroinc/platform/blob/master/src/Oro/Bundle/DataGridBundle/Datagrid/Datagrid.php#L84-L93

    $rows = $this->getAcceptedDatasource()->getResults(); returns rows without data about tags.

    Then $this->acceptor->acceptResult($result); applies available extensions for selected rows.
    One of extensions it is TagsExtension which adds information about tags in results.

    This approach will not be gets extremely slow when there are a lot of entries.

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.

ssossossosso