I currently have a logs table which has the following rows which use the same order_id
:
log_id | order_id | user | action |
---|---|---|---|
2410 | 1001318004 | test1 | Declined |
2409 | 1001318004 | test1 | Declined |
Inside my app/code/Vendor/Module/Model/ResourceModel/OrderTable/Collection.php
class file I have the following method to set the collection results:
protected function _initSelect()
{
$this->getSelect()->from(['main_table' => $this->getMainTable()]);
$this->getSelect()
->joinLeft(
['innox_prescriber_logs'['logs' => $this->getTable('innox_prescriber_logs''logs')],
'main_table.increment_id = innox_prescriber_logslogs.consultation_id'order_id',
['*','customer_name'=>'CONCAT_WS(" ",main_table.customer_firstname,main_table.customer_lastname)']
);
return $this->filterOrders();
}
where main_table
references the sales_order
table.
but when I view the results in the admin I get the following error:
Item (Magento\Framework\View\Element\UiComponent\DataProvider\Document) with the same ID "1557472" already exists.
The 1557472
refers to the entity ID matching the order for the 1001318004
increment ID.
What I'm looking for, is a way to only get the latest row if there are duplicates in the results.
Cheers guys