I want to show the duplicate entries in Admin Grid. that grid is created by join there tables. If any duplicate entry from my custom table, Grid returns the error as below,

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

how to disable this duplicate entry check in grid/collection.php My Collection.php is below,


namespace Webkul\Pos\Model\ResourceModel\Delivery\Grid;
use Psr\Log\LoggerInterface;
use Magento\Framework\ObjectManagerInterface;
use Magento\Framework\Event\ManagerInterface;
use Magento\Store\Model\StoreManagerInterface;
use Magento\Framework\Search\AggregationInterface;
use Magento\Framework\Api\Search\SearchResultInterface;
use Magento\Framework\Data\Collection\EntityFactoryInterface;
use Magento\Framework\Data\Collection\Db\FetchStrategyInterface;
use Webkul\Pos\Model\ResourceModel\Delivery\Collection as DeliveryCollection;

class Collection extends DeliveryCollection implements SearchResultInterface  {

    protected $_aggregations;
    protected $_objectManager;

    public function __construct(
        EntityFactoryInterface $entityFactory,
        LoggerInterface $logger,
        FetchStrategyInterface $fetchStrategy,
        ManagerInterface $eventManager,
        StoreManagerInterface $storeManager,
        ObjectManagerInterface $objectManager,
        $connection = null,
        \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource = null,
        $model = "Magento\Framework\View\Element\UiComponent\DataProvider\Document"
    )  {
        $this->_objectManager = $objectManager;
        $this->_eventPrefix = $eventPrefix;
        $this->_eventObject = $eventObject;
        $this->_init($model, $resourceModel);

    public function getAggregations()  {
        return $this->_aggregations;

    public function setAggregations($aggregations)  {
        $this->_aggregations = $aggregations;

    public function getSearchCriteria()  {
        return null;

    public function setSearchCriteria(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria = null)  {
        return $this;

    public function getTotalCount()  {
        return $this->getSize();

    public function setTotalCount($totalCount)  {
        return $this;

    public function setItems(array $items = null)  {
        return $this;


My model\ResourceModel\Delivery Collectio.php is below,

 namespace Webkul\Pos\Model\ResourceModel\Delivery;


class Collection extends AbstractCollection  {

    protected $_idFieldName = "order_id";

    protected function _construct()  {
        $this->_init("Webkul\Pos\Model\Delivery", "Webkul\Pos\Model\ResourceModel\Delivery");


    protected function _initSelect()
            'main_table.order_id = secondTable.entity_id','*');
            'main_table.order_id = thirdTable.entity_id', '*');


    public function setDeliveryData($condition, $attributeData)  {
        return $this->getConnection()->update($this->getTable("pos_delivery"), $attributeData, $where = $condition);


Anyone please help me.. Thanks in Advance

  • So you want show duplicate entries or want disable? Oct 10, 2018 at 10:32
  • i want to show duplicate entries @RutveeSojitra
    – Ask Xah
    Oct 10, 2018 at 10:36
  • If you want to show duplicate entry primary keywise it is not possible. because all mass action will perform on base of primary key Oct 10, 2018 at 10:37
  • no im doing all mass actions in a separate auto gen id. I want to show the duplicate entry of another key order_id from my cutom table @RutveeSojitra
    – Ask Xah
    Oct 10, 2018 at 10:38
  • Please add your Webkul\Pos\Model\ResourceModel\Delivery\Collection as DeliveryCollection code in question Oct 10, 2018 at 10:39

1 Answer 1


Please change

protected $_idFieldName = "order_id";


protected $_idFieldName= "id"

Because your custom tables primary key is id not order_id

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.