- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I'm getting the following error when tried to massDelete in admin grid for the custom module.
Exception #0 (Magento\Framework\Exception\LocalizedException): Invalid method Magento\Framework\View\Element\UiComponent\DataProvider\Document::delete
FYI:
i found two solutions regarding this both not worked for me.
1. In di xml already file path is having Grid folder
<virtualType name="Package\Modulename\Model\ResourceModel\xxxxx\Grid\Collection"
2. In listing.xml added missing line inside listing_massaction
<item name="selectProvider" xsi:type="string">.......</item>
Solved! Go to Solution.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I have tried all the solutions based on xml files. nothing worked.
In massDelete controller i have changed the for loop
From:
// foreach ($collection as $item) { // $item->delete(); // }
To:
$recordDeleted=0; foreach ($collection as $item) { $deleteItem = $this->_objectManager->get('Package\Module\Model\filename')->load($item->getId()); $deleteItem->delete(); $recordDeleted++; }
It worked for me.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Invalid method Magento\Framework\View\Element\UiComponent\DataProvider\Document::delete
Hello @Kiran
Did you check the below solution ?
https://magento.stackexchange.com/questions/182375/invalid-method-name-delete-in-magento-2
Also share your di.xml code if issue still persists.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I have tried all the solutions based on xml files. nothing worked.
In massDelete controller i have changed the for loop
From:
// foreach ($collection as $item) { // $item->delete(); // }
To:
$recordDeleted=0; foreach ($collection as $item) { $deleteItem = $this->_objectManager->get('Package\Module\Model\filename')->load($item->getId()); $deleteItem->delete(); $recordDeleted++; }
It worked for me.