I have successfully replicated part of the default Magento Sales Order Grid to display and filter another grid, this one regrouping the purchase orders instead.
I chose to replicate the Sales Order Grid as I want my grid to be synchronized in a similar way (on grid load and via cron) from the main table containing the purchase orders.
I have encountered an issue where when I register my handle for my grid, it shows up fine but on the other side unexpectedly the original Sales Order Grid give me the error that it's handled is not registered.
This is the error given:
Not registered handle sales_order_grid_data_source
I have realized that as soon as I comment out my module_purchaseorder_grid_data_source declaration in my di.xml file below, the Sales Order Grid starts working again. Of course the Purchase Order one does not anymore.
<config> <type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory"> <arguments> <argument name="collections" xsi:type="array"> <item name="module_purchaseorder_grid_data_source" xsi:type="string">NameSpace\Module\Model\Resource\PurchaseOrder\Grid\Collection</item> </argument> </arguments> </type> <virtualType name="NameSpace\Module\Model\Resource\PurchaseOrder\Grid\Collection" type="Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult"> <arguments> <argument name="mainTable" xsi:type="string">purchase_order_table_grid</argument> <argument name="resourceModel" xsi:type="string">NameSpace\Module\Model\Resource\PurchaseOrder</argument> </arguments> </virtualType> </config>
I'm not sure to understand what is interfering. I revised my code to see if I would be rewriting anything from Sales Order by mistake and I do not (I searched through all of my module files with different keywords). I have completely remove Magento Sales Order module and replaced it with original files in case I would have edited one by mistake while digging. I did dig up in Magento code and to find how the Sales Order Grid data source is retrieved.
This page from mage2.pro resumes it a bit:
If someone knowledgeable enough regarding the Sales Order Grid could point in the right direction as where the interference might be residing it would be appreciated. I did not share all of the related code but looking at the Sales Order and Sales Order Grid models one should be able to see the pattern, I have replicated it in almost the same exact way. Someone might be able to pinpoint which config/class would be more eligible to influence a completely different module (Sales) and I would be pleased to share this specific part on request.