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

Forums OroCRM OroCRM – How do I? Questions Datagrid using one of "oro_rel_…" table.

This topic contains 2 replies, has 2 voices, and was last updated by  czaros45 6 months, 3 weeks ago.

  • Creator
  • #58291


    Hi everyone,

    I need to make a datagrid with customers and their activities. I would like to see something like that:

    Name of the customer:_________Number of activities:
    CustomerA __________________________3
    CustomerB __________________________5

    I found a table called: oro_rel_c3990ba6784fec5f23d770 and it solves my problem since it stores relation between customer_id and activity_id.
    My approach would be like this:
    1. Code a method which contains DQL query where I hardcode this name (it feels like it’s a not right way to do it)
    2. According to this documentation I can make a class a service and use it in “query” field in datagrid:

    I’m forced to do it with a service because this:

    calls that Class oro_rel_c3990ba6784fec5f23d770 does not exist.

    My questions are:
    – Is it simplier solution to this that I’m missing?
    – How to get the name of the table in not hardcoded way? I found a Class ExtendDbIdentifierNameGenerator.php and a method generateManyToManyJoinTableName() which generates this name, although I cannot find a way to retrieve that name.

    Thanks in advance.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Author
  • #58292

    Hello, czaros45
    1) You are right you can’t use table name, it should be entity name
    2) In your example you are using only one table ManyToMany, here we can see that Account has at least two types of activities

    So I would recommend you to create listener for data grid on event “onResultAfter” and add column to result set.
    Count of all activities can be fetched from ActivityRepository for your case it will be great create query that will work with array of accounts.

    Or another way your can try to create listener on event ‘onBuildAfter’ and implement similar query from ActivityRepository at datagrid config but it wont be easy



    Hi ypetrov,

    I created listener for data grid on event “onResultAfter” and for each record I calculated activities count and added them to the column. Your approach worked :) Thank you for your answer!


Viewing 2 replies - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.