OroCRM Forums

Covering OroCRM topics, including community updates and company announcements.

Forums Forums OroCRM OroCRM – How do I? Questions Adding relationship (and foreign key) between entities

This topic contains 2 replies, has 2 voices, and was last updated by  oro_newbie 6 years, 2 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
  • #28981

    oro_newbie
    Participant

    Hi,

    Following the guide here, I chose Doctrine Relations and below is my code:

    Now when I get an existing object of product, $prod_obj->getCategory() should be giving me the category of the product but it’s null. The foreign key relation in the DB isn’t made either. Should I be running any commands after this?

    How exactly can I get the category name (let’s say category_name from Category entity) using the $prod_obj? The common link between them is the column – category_id (assume same name in both tables).

    Thanks.

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

    Mike Kudelya
    Participant

    Hi,

    I have tested your case, on my side it is working, but i think it is a bit incorrect, because general entity should be Product, but now vice versa. I advise you read these acticles: first and second. They will help you better understand doctrine relations.

    Product entity:

    Category entity:

    Migration:

    Create category:

    Create product:

    And finally got category name:

    #28983

    oro_newbie
    Participant

    Hi Mike,

    The 2 articles that you linked really helped. I was able to identify what’s wrong with the relationship I was trying to create between my entities.

    Thank you! Marking this problem as resolved.

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

The forum ‘OroCRM – 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