I am working on a module, where I have 2 custom tables. One is of all customer who have added product to First table(one customer can add multiple tables) and that first table is displayed on grid.

On grid action I have a action column which has to show all products added added by a customer.

My frist tables structure( table name->rfq)

frist table

my second tables structure (table name->rfqitem) second table

this code gives output like below

    protected function _initSelect()

        ['secondTable' => $this->getTable('rfq')],
        'main_table.rfq_id = secondTable.customer_id', 

current output getting

but i expect result like this expect So how can achieve this.


  • Share your code what you have tried. So i can check. – Kirti Nariya Nov 21 '18 at 7:58
  • please check my updated Questin – Adarsh Shukla Nov 21 '18 at 9:27
  • Please check my answer. – Rohan Hapani Nov 21 '18 at 9:46

You need to add where clause in joinLeft() query :

        ['secondTable' => $this->getTable('rfq')],
        'main_table.rfq_id = secondTable.customer_id', 
    )->where("main_table.id IS NOT null");
  • Item (Magento\Framework\View\Element\UiComponent\DataProvider\Document) with the same ID "2" already exists. This error is raised – Adarsh Shukla Nov 21 '18 at 10:03
  • Use ->group("main_table.id"); after where() – Rohan Hapani Nov 21 '18 at 10:35
  • Please upvote again :) – Rohan Hapani Nov 21 '18 at 11:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.