OroPlatform Forums

Covering OroPlatform topics, including community updates and company announcements.

Forums Forums OroPlatform OroPlatform – How do I? Questions Many-To-Many relation between User and Custom entities

This topic contains 5 replies, has 4 voices, and was last updated by  archy_bold 6 years, 5 months ago.

Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.

  • Creator
  • #36070


    I need to create Many-To-Many relation between User and Room (custom extended entity) entities. Then I need to display grid with Users on Room update page, and grid with Rooms on User update page. I have 2 ideas how to do that, but in each of them I had problems.

      Create migration script and add entity via ->addManyToManyRelation(). – But here I faced with problem, that I use e.g. User->getRooms(), because I can’t add this function to User entity class.
      Rewrite OroUserBundle and rewrite User entity class. – But here I faced with problem, that when I copy /Entity/User.php file to my custom bundle and when I run php app/console doctrine:schema:update --dump-sql, it display error, that ‘oro_user’ table already exist.

    What is the best way to add Many-To-Many relation between User and Custom entities?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Author
  • #36071

    Vova Soroka


    The right way is to create extended many-to-many relation in a migration script.
    The ExtendExtension::addManyToManyRelation is intended to do it. But in your case you need bidirectional relation, because you want to display related entities on both owning and target sides.
    Unfortunately, it is not possible to create a bidirectional relation using a migration script. I’ve reported this issue. We’ll try to prepare a fix ASAP.




    Any update on this? I am running into the same issue with a build from November and wondering if this has been fixed in the latest source.




    This is also something that’s tripped me up. An update on how to achieve it would be great.


    Vova Soroka

    Hi all,

    Sorry for the late message.
    The bidirectional relations have been already implemented. Please see details in https://github.com/orocrm/platform/blob/master/src/Oro/Bundle/EntityExtendBundle/Resources/doc/relations.md



    Ah cool. Is there more to adding relations through the EntityExtendBundle? I’ve managed to add the relation but when I call getSubscriptions on my model, I always get null. Even with data in the database.

    Should the extended model have annotations for Doctrine or do I need to define them in my own model?

    My extended entity class looks as follows:

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

The forum ‘OroPlatform – How do I? Questions’ is closed to new topics and replies.

Back to top

You will be redirected to [title]. Would you like to continue?

Yes No

You will be redirected to [title]. Would you like to continue?

Yes No