2

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()
{
    parent::_initSelect();

    $this->getSelect()->joinLeft(
        ['secondTable' => $this->getTable('rfq')],
        'main_table.rfq_id = secondTable.customer_id', 
        array('main_table.product_id','main_table.qty')
    );
}    

current output getting

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

thanks

3
  • Share your code what you have tried. So i can check. Commented Nov 21, 2018 at 7:58
  • please check my updated Questin Commented Nov 21, 2018 at 9:27
  • Please check my answer. Commented Nov 21, 2018 at 9:46

1 Answer 1

3

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

$this->getSelect()->joinLeft(
        ['secondTable' => $this->getTable('rfq')],
        'main_table.rfq_id = secondTable.customer_id', 
        array('main_table.product_id','main_table.qty')
    )->where("main_table.id IS NOT null");
4
  • Item (Magento\Framework\View\Element\UiComponent\DataProvider\Document) with the same ID "2" already exists. This error is raised Commented Nov 21, 2018 at 10:03
  • Use ->group("main_table.id"); after where() Commented Nov 21, 2018 at 10:35
  • Please upvote again :) Commented Nov 21, 2018 at 11:05
  • how it can be done using UI component? Commented Sep 29, 2021 at 9:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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