OroPlatform Forums

Covering OroPlatform topics, including community updates and company announcements.

Forums Forums OroPlatform OroPlatform – Programming Questions Entity Relation ManyToMany changed to be ManyToOne-OneToMany

This topic contains 5 replies, has 2 voices, and was last updated by  Alexandr Smaga 10 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
  • #33292

    jevjev
    Participant

    Hello, I’m newbie in Symfony and also new with Oro. From what I see, this system is great but still too complex for me to comprehend all. I need to add a little bit customization.
    I want to add Order-Product like subsystem (I use sample code).

    I have problem with entity relation. When using ManyToMany relation, it seems all fine

    MANY-TO-MANY CODE (this is fine, no problem, just comparison)

    MANY-TO-MANY CODE (this is fine, no problem, just comparison)

    Then I have a need to use ManyToOne-OneToMany relation instead of using ManyToMany relation. Here is my code (ideally like this, but practically I got error):

    From above code, I can’t get orderproducts-added or orderproducts-removed because added orderproduct not found from db (of course because this is actually collection of product id)

    Then after I try changed a bit, the class changed to be Product, but held by default_orderproduct & orderproducts builder, would result problem too

    Of course would cause problem, my manipulation just for testing, just trying to find a way. When get data from db to be put into form data, would result error incompatible class Product with Orderproduct.

    My Question, Can OroCrm using ManyToOne-OneToMany relation as alternative to ManyToMany relation?

    Thanks

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

    Alexandr Smaga
    Participant

    Hello.

    I’m sorry but your question is not clear. Can you just describe the main idea what do you want to make ?
    Do you need some form where you would like to create order with order items based on product entity ?

    #33294

    jevjev
    Participant

    Thanks for replying, asmaga

    Sorry if my question is not clear.

    from my last post:
    “My Question, Can OroCrm using ManyToOne-OneToMany relation as alternative to ManyToMany relation?”

    The point is can I create module with ManyToOne-OneToMany relation entities?

    According to doctrine document, we can change ManyToMany with ManyToOne-OneToMany

    http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/association-mapping.html#many-to-many-unidirectional

    Why are many-to-many associations less common? Because frequently you want to associate additional attributes with an association, in which case you introduce an association class. Consequently, the direct many-to-many association disappears and is replaced by one-to-many/many-to-one associations between the 3 participating classes.

    #33295

    Alexandr Smaga
    Participant

    Hi.

    Of course it can. I’ve started preparing demo bundle for you. It’s not finished yet from UI point, but you can take a look on mappings for entities. Here it is. Keep in mind that some features were skipped for the quickest reply (such as ACL, REST controller for delete etc..)

    Happy new year and best wishes!

    #33296

    jevjev
    Participant

    Thank you very much Asmaga, this is very helpful.

    #33297

    Alexandr Smaga
    Participant

    You are welcome.
    I’ve just updated UI fixes, please check it out.

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

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

Back to top