I built my own custom admin grid. It renders the data correctly, however when I tried to filter on an input, I am receiving the following error from the ajax request:
Status code 500
Error:
TypeError: Magento\Sales\Plugin\Model\ResourceModel\Order\OrderGridCollectionFilter::aroundAddFieldToFilter():
Argument #1 ($subject) must be of type Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult, Vendor\ModuleName\Model\ResourceModel\MoodleLogs\Grid\Collection\Interceptor given,
called in /var/www/html/vendor/magento/framework/Interception/Interceptor.php on line 135 and defined in /var/www/html/vendor/magento/module-sales/Plugin/Model/ResourceModel/Order/OrderGridCollectionFilter.php:41
Interesting part is that I don't have any dependencies from the Magento Sales module. This is my di.xml part:
<virtualType name="Vendor\ModuleName\Model\ResourceModel\MoodleLogs\Grid\Collection" type="Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult">
<arguments>
<argument name="mainTable" xsi:type="string">moodle_logs</argument>
<argument name="resourceModel" xsi:type="string">Vendor\ModuleName\Model\ResourceModel\MoodleLogs</argument>
<argument name="eventPrefix" xsi:type="string">vendor_modulename_logs_grid_collection</argument>
<argument name="eventObject" xsi:type="string">vendor_logs_grid_collection</argument>
</arguments>
</virtualType>
<type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
<arguments>
<argument name="collections" xsi:type="array">
<item name="vendor_modulename_moodle_logs_grid_data" xsi:type="string">Vendor\ModuleName\Model\ResourceModel\MoodleLogs\Grid\Collection</item>
</argument>
</arguments>
</type>
and this is part of my UI component:
<dataSource name="bookingsystem_bookings_list_data_source">
<argument name="dataProvider" xsi:type="configurableObject">
<argument name="class" xsi:type="string">Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider</argument>
<argument name="name" xsi:type="string">vendor_modulename_moodle_logs_grid_data</argument>
<argument name="primaryFieldName" xsi:type="string">entity_id</argument>
<argument name="requestFieldName" xsi:type="string">id</argument>
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="update_url" xsi:type="url" path="mui/index/render"/>
<item name="storageConfig" xsi:type="array">
<item name="indexField" xsi:type="string">entity_id</item>
</item>
</item>
</argument>
</argument>
<argument name="data" xsi:type="array">
<item name="js_config" xsi:type="array">
<item name="component" xsi:type="string">Magento_Ui/js/grid/provider</item>
</item>
</argument>
</dataSource>
<listingToolbar name="listing_top">
<settings>
<sticky>true</sticky>
</settings>
<columnsControls name="columns_controls"/>
<paging name="listing_paging"/>
<filters name="listing_filters">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="templates" xsi:type="array">
<item name="filters" xsi:type="array">
<item name="select" xsi:type="array">
<item name="component" xsi:type="string">Magento_Ui/js/form/element/ui-select</item>
<item name="template" xsi:type="string">ui/grid/filters/elements/ui-select</item>
</item>
</item>
</item>
</item>
<item name="observers" xsi:type="array">
<item name="column" xsi:type="string">column</item>
</item>
</argument>
</filters>
</listingToolbar>
Not sure why Ii am getting that error from the magento/module-sales plugin . Any idea ?
If I disable the core plugin, it works:
<type name="Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult">
<plugin name="orderGridCollectionFilterPlugin" type="Magento\Sales\Plugin\Model\ResourceModel\Order\OrderGridCollectionFilter"/>
</type>
Thanks