OroCRM Forums

Covering OroCRM topics, including community updates and company announcements.

Forums 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 7 years, 11 months ago.

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

  • Creator
    Topic
  • #25204

    Edmund
    Participant

    Hello,

    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)?

    Thanks!

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

    Edmund
    Participant

    “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)

The forum ‘OroCRM – Programming Questions’ is closed to new topics and replies.

Back to top