ssossossosso

Forums

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

This topic contains 2 replies, has 2 voices, and was last updated by oro_newbie oro_newbie 1 year, 1 month ago.

  • Creator
    Topic
  • #21524
    oro_newbie
    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
  • #21567
    Mike Kudelya
    Mike Kudelya
    Oro Core

    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:

    #21569
    oro_newbie
    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)

You must be logged in to reply to this topic.