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.


    <type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
            <argument name="collections" xsi:type="array">
                <item name="module_purchaseorder_grid_data_source" xsi:type="string">NameSpace\Module\Model\Resource\PurchaseOrder\Grid\Collection</item>

    <virtualType name="NameSpace\Module\Model\Resource\PurchaseOrder\Grid\Collection" type="Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult">
            <argument name="mainTable" xsi:type="string">purchase_order_table_grid</argument>
            <argument name="resourceModel" xsi:type="string">NameSpace\Module\Model\Resource\PurchaseOrder</argument>

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:

How are the rows data retrieved for the backend's orders grid?.

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.


1 Answer 1


The problem is that you have the di.xml with your collection handle in the etc/adminhtml directory while Magento puts these declarations in the base area, /etc/di.xml. This is resulting in the handle for the Sales Order Grid (and all other grids) being ignored because a more specific adminhtml xml declaration exists.

You need to move etc/adminhtml/di.xml to etc/di.xml.

  • Hi Aaron, thank you very much for your answer. As soon as I read it, it sounded very logic and it seems that Magento found it logic too as it worked instantly. Now both grids are displaying as they should and nothing is ignored. Not to overlook the folder hierarchy, I will remember this one.
    – ElGatito
    Commented Nov 26, 2016 at 21:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.