1

All the Grid's from Sales menus are giving Not registered handle error.

Grid's from Catalog menus are working fine.

Some custom grids are working and some are not, even I have installed a new module and its grid is also not working giving the same error.

I am using Magento 2.2.3

Most of the answers to other questions mentioned to move "etc/adminhtml/di.xml" code to "etc/di.xml", but

Questions:

  1. Newly installed custom module is having only a single di.xml which is inside "etc/" folder. There is no di.xml inside etc/adminhtml folder than what is the issue?

  2. Sales module comes with magento, is it still requires to move code from "etc/adminhtml/di.xml" code to "etc/di.xml"

  3. If its due to any other module, is there is a way to identify that module.

  • I'm experiencing the same thing. All admin-side UI Component grids who use a dataSource defined in DI as an argument to the UIComponent\DataProvider\Collection factory's "collection" argument, are non functional. Examples of this include grids in the Sales module, and Customer module. These collection types are all defined in the module's etc/di.xml file. Moving these configurations to etc/adminhtml/di.xml fixes the issue, but surely this is not the right solution. I've cleared cache and deployment mode is set to developer-- what am I missing? – John Hall Feb 4 at 19:49
1

Alright, I was having the same issue and formed a conclusion that I misunderstood how Magento parses Dependency Injection files.

I started by pausing execution during the Object Manager configuration process, that can be done by putting a break point in the configure method of Magento\Framework\ObjectManager\ObjectManager

I dove into the config property of the Object Manager and into its _arguments and found the list of parameters for the collections argument of Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory

It looked like this: Configured collection types

As you can see, all of the supposedly "unregistered" data sources are right there, as you'd expect.

So far, all is well.

However, this isn't the only time the Object Manager is configured. The next time it is configured, it is parsing configurations for the current application area (in this case, adminhtml). This time around, the collections argument only contained data sources I had named in my module's etc/adminhtml/di.xml files and therefore the "Not registered handle" exception was thrown for any Grid calling for a Collection declared in the module's "Global" DI file (i.e., module/etc/di.xml).

Here is where I had misunderstood Magento's DI Compiling/Resolution

I thought (apparently, incorrectly) that when parsing XML files (such as DI files), Magento always marges matching nodes to build out the XML structure it uses and therefore, arguments such as these could be declared in either the module's Global DI configuration (i.e., module/etc/di.xml) OR in the module's area-specific DI configuration (e.g., module/etc/adminhtml/di.xml) and everything would work as you'd expect. Wrong!

In my defense, I think my understanding is a reasonable conclusion from Magento's documentation which reads:

Each module can have a global and area-specific di.xml file. Magento reads all the di.xml configuration files declared in the system and merges them all together by appending all nodes

So yeah, I think that could be worded a bit better...

So here's the take-away (tl;dr)

When parsing DI configuration files, declarations from the area-specific files such as etc/adminhtml/di.xml will override argument declarations from the Global DI file. Therefore, if you're going to do something like this:

<type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
    <arguments>
        <argument name="collections" xsi:type="array">
            <item name="your_data_source_name" xsi:type="string">...</item>
        </argument>
    </arguments>
</type>

You MUST declare such configuration in your module's "Global" DI Configuration file (i.e., module/etc/di.xml otherwise you will effectively "override" all other DI configuration for the "collections" argument of the targeted type.

This is a confusing problem to debug/understand if you have a couple of modules you have written, both following the same method of declaring arguments in the area-specific DI file. In this scenario, your UI Components will work, but built-in Magento components will not. This is because, as I've explained, declaring arguments in the area-specific di.xml will override arguments in the Global di.xml file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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