cancel
Showing results for 
Search instead for 
Did you mean: 

Invalid method Magento\Framework\View\Element\UiComponent\DataProvider\Document::delete

SOLVED

Invalid method Magento\Framework\View\Element\UiComponent\DataProvider\Document::delete

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>

 

 

 

 
 
1 ACCEPTED SOLUTION

Accepted Solutions

Re: Invalid method Magento\Framework\View\Element\UiComponent\DataProvider\Document::delete

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.

 
 

View solution in original post

2 REPLIES 2

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.

Problem Solved ? Click on 'Kudos' & Accept as Solution ! Smiley Happy

Re: Invalid method Magento\Framework\View\Element\UiComponent\DataProvider\Document::delete

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.