cancel
Showing results for 
Search instead for 
Did you mean: 

Join two tables and got Item with the same ID already exists.error

Join two tables and got Item with the same ID already exists.error

Hello,

I have to do a form where customer can manage prices for products.

We have three tables 

1.   group_id; group_name

2.   entity_id; group_id; some_id

3.   item_id; group_id;sku; price

 

So, i want to fetch all items and show their some_id.

 

I'm using grid collection for table 3. I've added this join

protected function _initSelect()
    {
       parent::_initSelect();
        $linkTable = $this->getTable('TABLE_2');
        $this->getSelect()
            ->join(
                ['link' => $linkTable],
                'main_table.group_id = link.group_id'
            );
        $this->getSelect()->group(['main_table.group_id','link.some_id']);
    }

Rersult of this quesry is image.jpeg

 

 

 

 

 

 

And then i pass this collection into admin grid i got 

(Magento\Framework\View\Element\UiComponent\DataProvider\Document) with the same ID "48" already exists.

Maybe someone know how to fix it. or maybe i have to use something different ?

Thanks.

1 REPLY 1

Re: Join two tables and got Item with the same ID already exists.error

WhatsApp Image 2021-04-09 at 18.51.03.jpeg