10

If I go to "Sales" under Magento 2, I have several menu options. And every single one of those options has an error relating to that section:

Orders: Not registered handle sales_order_grid_data_source Invoices: Not registered handle sales_order_invoice_grid_data_source Shipments: Not registered handle sales_order_shipment_grid_data_source Credit Memos: Not registered handle sales_order_creditmemo_grid_data_source

And so on. I was on Magento 2.0.x earlier and the issue wasn't there. I don't know when the issue appeared because this store is in development and not active. But I've since updated to 2.1.0 then 2.1.3 this week, and not sure when the problem occurred. Anything helpful would be great.

0

6 Answers 6

48

The problem here is that someone defined a handle in the etc/adminhtml/di.xml

search for something like this

<type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
    <arguments>
        <argument name="collections" xsi:type="array">
            <item name="NameOfHandle" xsi:type="string">Vendor\Module\Model\ResourceModel\Something\Collection</item>
        </argument>
    </arguments>
</type>
<virtualType name="Vendor\Module\Model\ResourceModel\Something\Collection" type="Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult">
    <arguments>
        <argument name="mainTable" xsi:type="string">NameOfTable</argument>
        <argument name="resourceModel" xsi:type="string">Vendor\Module\Model\ResourceModel\Something</argument>
    </arguments>
</virtualType>

Do not search for the handle that he can not find. Just go over etc/adminhtml/di.xml in your modules and search for

<type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">

Move that bit of code to etc/di.xml instead of etc/adminhtml/di.xml

8
  • 3
    This should be the accepted answer. May 3, 2018 at 22:20
  • if I move the <type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory"> to etc/di.xml file it's not working, but the "Not registered handle" error gone
    – senthil
    Jun 21, 2018 at 14:06
  • What is your di.xml noNamespaceSchemaLocation ? be sure it is set to urn:magento:framework:ObjectManager/etc/config.xsd Jun 22, 2018 at 2:49
  • the Actual problem is with di.xml After checking that this problem will solved.. :)
    – Ask Xah
    Oct 7, 2018 at 10:55
  • 1
    Check this hungersoft.com/info/… for more info
    – hungersoft
    Jan 1, 2020 at 3:44
16

Okay so I found the problem. I found another stackexchange topic that didn't seem to be 100% related because it was a different module, however the exact same scenario was occurring. You can find the discussion here: https://stackoverflow.com/questions/39763550/magento-2-1-1-admin-content-pages-not-loading-handle-not-registered

The main thing was that I didn't create any custom modules, but I did install a few modules from third parties. I guess I just assumed these would have been updated, but they were manually installed not with composer, there were minor issues with the setup of the modules file structure. Being new to Magento I looked at the topic above and was just looking at the Magento file structure, but then it clicked I needed to look at the file structure of the modules.

Once, I investigated each of the modules I had installed, I looked in the etc/adminhtml directory for each and I found a few of them had a di.xml file in that directory, and also an etc/di.xml. So I opened both files, compared them, and combined them. I only added what was missing from the adminhtml path into the etc/di.xml path. Then I renamed the etc/adminhtml/di.xml to bak.di.xml just to back it up. I cleared and flushed the cache, and everything is working again.

It appears to me that this is a change from 2.0.x to 2.1.x. Most modules will be fine working from 2.0.x to 2.1.x but that file structure is what caused my issues.

3
  • Thank you Jason, I did as you mentioned here, though I did not copy all the code of di.xml of adminhtml folder to etc/di.xml but I commented all the code of di.xml of adminhtml folder & all the things are working fine now :) So yes you are right that there is something with di.xml in adminhtml folder.
    – KA9
    Aug 30, 2017 at 9:49
  • I made an answer what is causing this after i got this issue myself, Thanks for the lead to the solution Apr 2, 2018 at 17:55
  • So, we cannot create di.xml under adminhtml?
    – AshwinP
    Jul 26, 2018 at 10:38
11

The self-provided answer from @jason-diehl doesn't really explain this issue, and I believe includes some incorrect information.

I ran into this issue when developing a custom module and testing the admin grid. I could see the container with the "Add ____" button, but a single message: Not registered handle ________. After looking into things I realized that I had specified a <dataSource> name in my view/adminhtml/ui_component/my_module_controller_listing.xml file which was not included in my etc/di.xml file as a named <item> in the list of collections for the Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory type.

Once I adjusted the name of the data source in my listing to match the name of the collection in etc/di.xml, the error was gone.

So to summarize: When you specify a data source to use in your adminhtml grid listing UI component(s), you must make sure the name attribute of your data source is specified as the name of a collection under the <type> tag of Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory.

2
  • Truly helped me. It really explained the issue and should be better rated imho :) Jul 1, 2019 at 8:19
  • This is a good answer. In the latest official doc, adminhtml grid requires di.xml configuration for CollectionFactory.. (not sure whose great idea it was to make setting up vanilla grid through "DI")
    – laketuna
    Jan 3, 2021 at 2:43
9

"Move that bit of code to etc/di.xml instead of etc/adminhtml/di.xml"

Everyone is suggesting for moving code from etc/adminhtml/di.xml to etc/di.xml. Don't understand. why to move ? When gone inside this then found that etc/adminhtml/di.xml has greater priority over etc/di.xml i.e. if any of the single module inside app/code/, if defined di.xml datasource inside etc/adminhtml/di.xml, then it will not look for etc/di.xml for same type in other modules, and modules stopped and show error Not registered handle.

so, if you are going to define type in code section be sure that it is in a right place, and as I can see people have made etc/di.xml as Right place to define type for Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory.

for example -

etc/di.xml

<type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">

etc/adminhtml/di.xml

<type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">

When same type is defined in above two files, then priority will be given to etc/adminhtml/di.xml

I define it inside, etc/adminhtml/di.xml, have a look :)

https://github.com/gitamitgit/sample-admin-module

4
  • You can define it there but it will break your other modules. Infact if you search the codebase for the declarations in di.xml files - not a single module declares this in etc/adminhtml/di.xml Jul 28, 2021 at 10:18
  • @ol'bobdole On Magento 2.3, I see that 284 di.xml files are directly in etc/, and 255 di.xml files are in etc/some_area/. Those areas are frontend, adminhtml, webapi_soap, webapi_rest, graphql, and others.
    – dotancohen
    Jun 1, 2022 at 6:04
  • @dotancohen in some instances, for the type being defined, it matters what area it is defined in. Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory is one of them. Jun 1, 2022 at 12:05
  • 1
    I've found that if a new module is defined, using etc/adminhtml/di.xml should work without issue. But if you are overwritting an existing <item> defined by an existing module (ie. vendor/magento/) and that module initially declared it at etc/di.xml, then using etc/adminhtml/di.xml will result in breaking other modules that depend on that <item>. So to summarize, new modules should be able to use etc/adminhtml/di.xml safely, but when overwritting a module use the same tier as that parent module.
    – PromInc
    Jul 8, 2022 at 15:55
1

For My case, I did all. But forgot to run bin/magento setup:di:compile

after run its working.

0

Moving the di.xml to /etc does not help in my case, i also added the following lines into my di.xml (i'm rewriting the sales_order_grid_data_source)

<item name="sales_order_invoice_grid_data_source" xsi:type="string">Magento\Sales\Model\ResourceModel\Order\Invoice\Grid\Collection</item>
<item name="sales_order_shipment_grid_data_source" xsi:type="string">Magento\Sales\Model\ResourceModel\Order\Shipment\Grid\Collection</item>
<item name="sales_order_creditmemo_grid_data_source" xsi:type="string">Magento\Sales\Model\ResourceModel\Order\Creditmemo\Grid\Collection</item>
<item name="sales_order_view_invoice_grid_data_source" xsi:type="string">Magento\Sales\Model\ResourceModel\Order\Invoice\Orders\Grid\Collection</item>
<item name="sales_order_view_shipment_grid_data_source" xsi:type="string">Magento\Sales\Model\ResourceModel\Order\Shipment\Order\Grid\Collection</item>
<item name="sales_order_view_creditmemo_grid_data_source" xsi:type="string">Magento\Sales\Model\ResourceModel\Order\Creditmemo\Order\Grid\Collection</item>

Your Answer

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

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