OroCRM Forums

Covering OroCRM topics, including community updates and company announcements.

Forums Forums OroCRM How join two tables in orocrm grid, Is there any special way to doing this

This topic contains 3 replies, has 2 voices, and was last updated by  ibratsilo 5 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
  • #30904

    chathura
    Participant

    What I want is,

    I have defined following in entity PurchaseOrderItem

    /**
    * @var Product
    *
    * @ORM\ManyToOne(targetEntity=”Testcompany\Bundle\ProductBundle\Entity\Product”)
    * @ORM\JoinColumn(name=”product_id”, referencedColumnName=”id”)
    */
    private $productId;

    My Datagrid

    purchase-order-items:
    source:
    type: orm
    query:
    select:
    – poi
    from:
    – { table: Testcompany\Bundle\PurchaseOrderBundle\Entity\PurchaseOrderItem, alias: poi }
    join:
    left:
    – { join: Testcompany\Bundle\ProductBundle\Entity\Product, alias: product, conditionType: WITH, condition: “product.id = poi.product_id” }

    columns:
    productId:
    label: sp.po.item.product_id.label
    frontend_type : integer
    poId:
    label: sp.po.header.id.label
    frontend_type : integer
    qty:
    label: sp.po.item.order_qty.label
    frontend_type : integer
    costPrice:
    label: sp.po.item.cost_price.label
    frontend_type : string
    createdAt:
    label: sp.po.header.created_at.label
    frontend_type: datetime
    updatedAt:
    label: sp.po.header.updated_at.label
    frontend_type: datetime

    But grid data is not showing as I expected. Please if anyone can post steps to joining two tables in OROCRM it will really helpful for me.

    thank you,
    Chathura

Viewing 3 replies - 1 through 3 (of 3 total)
  • Author
    Replies
  • #30905

    ibratsilo
    Moderator

    Hi, thanks for your question.

    At first you should understand Docrine ORM principles. So I suggest you to read documentation a bit – https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/association-mapping.html#association-mapping.

    In a nutshell, ORM implies the interaction of objects and you should not think about ids. So your class property should be private $product; without id in the end.

    And your join in this case should be like this:

    #30906

    chathura
    Participant

    HI Ibratsilo,

    wow…..Thank you very much it’s working.

    #30907

    ibratsilo
    Moderator

    I am glad to help!

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

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

Back to top