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
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
It looked like this:
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.,
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:
<argument name="collections" xsi:type="array">
<item name="your_data_source_name" xsi:type="string">...</item>
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