Forums OroCRM OroCRM – Programming Questions Bidirectional relationship of custom regular entity and OroCRM's Contact entity?

This topic contains 1 reply, has 1 voice, and was last updated by  Edmund 1 year, 8 months ago.

  • Creator
  • #22584



    I want to add a new Doctrine entity with relation to OroCRM’s “Contact” entity.

    For instance, I have a new entity class called “Activity”. This is a “Regular Entity” written in PHP class.
    Now, I want to set up a relationship so that a “Contact” can have many “Activities”.

    Being a developer with Symfony2 & Doctrine background, I know that this can be done by:

      adding the @ManyToOne annotation to the $contact field of the “Activity” class, and
      add a new field $activities to the “Contact” entity class, and add the @OneToMany annotation to it.

    But now “Contact” class is a part of the OroCRM, and I’ve read that there is currently no way to extend the original “Contact” class and tell the platform to use the extended one. It seems that I need to use a migration script to add the @OneToMany annotation equivalent. And that’s where I stuck. I would like to know:

      Is it possible to achieve what I want to do, i.e. setting up a bidirectional relationship to my new Regular entity and OroCRM’s Contact entity? If yes, is there any example I can refer to?
      One of the reason a bidirectional relationship is preferred is that I want to be able to something like $contact->getActivities(). Is it possible via existing mean(s)?


Viewing 1 replies (of 1 total)
  • Author
  • #22585


    “Activity” isn’t a good example because there exists an “activity” relation in the CRM. However, my question remains.

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.