cancel
Showing results for 
Search instead for 
Did you mean: 

Customer Groups Mass Delete Action Returns Invalid Method Exception

Customer Groups Mass Delete Action Returns Invalid Method Exception

Hi everybody,

hope you can help me solving this problem. I can't see the problem. 

 

I created an extension to display a custom admin grid in my administration backend. Everything works fine. All data is displayed in the grid. Now I want to delete all entries in this table with a mass delete action. So I created a controller to do this. The execute method in my class looks like this: 

$collection = $this->_filter->getCollection($this->_codeBlocksFactory->create());
                foreach ($collection as $item) {
                    $item->delete();
                }

Every time when I try to execute these I get the following exception: 

string(87) "Invalid method Magento\Framework\View\Element\UiComponent\DataProvider\Document::delete"

I actually don't know where the problem occures. I don't understand why my returning object is not from the model type I created for this extension. 

 

Maybe someone of you have an idea to solve this problem? 

Thanks a lot!

Michael

8 REPLIES 8

Re: Customer Groups Mass Delete Action Returns Invalid Method Exception

CRUD model methods are deprecated, use Repositories instead.

Re: Customer Groups Mass Delete Action Returns Invalid Method Exception

Check the di.xml
virtual type has to have Grid\ before Collection

And item the same inside the the argument

…….\Grid\Collection

Re: Customer Groups Mass Delete Action Returns Invalid Method Exception

I had same issue to resolve this issue you need to make change in di.xml file.

 

In virtual type:  Check bold part  you need to add that before collection.

 

<virtualType name="Company\Module\Model\ResourceModel\Tracks\Grid\Collection" type="Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult">

 

Same in type:

 

<type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
        <arguments>
            <argument name="collections" xsi:type="array">
                <item name="company_module_listing_data_source" xsi:type="string">Company\Module\Model\ResourceModel\Tracks\Grid\Collection</item>
            </argument>
        </arguments>
    </type>

 

You need to write Grid before collection at both place to fix the issue.

 

I hope this helps.

Re: Customer Groups Mass Delete Action Returns Invalid Method Exception

Thanks, 

Work for me

Re: Customer Groups Mass Delete Action Returns Invalid Method Exception

Thanks it's solve my problem

Re: Customer Groups Mass Delete Action Returns Invalid Method Exception

Thanks @jacktorris 

 

This helps me.

Magento Developer
Ankita Biswas

Re: Customer Groups Mass Delete Action Returns Invalid Method Exception

thanks

Re: Customer Groups Mass Delete Action Returns Invalid Method Exception

Thanks a lot, this solution works!