2

Hello!
There is a part of regular app/etc/di.xml and I need to add additional value in readers array.

 <virtualType name="bodyRenderPool" type="Magento\Framework\View\Layout\ReaderPool">
        <arguments>
            <argument name="readers" xsi:type="array">
                <item name="container" xsi:type="string">Magento\Framework\View\Layout\Reader\Container</item>
                <item name="block" xsi:type="string">Magento\Framework\View\Layout\Reader\Block</item>
                <item name="move" xsi:type="string">Magento\Framework\View\Layout\Reader\Move</item>
                <item name="uiComponent" xsi:type="string">Magento\Framework\View\Layout\Reader\UiComponent</item>
            </argument>
        </arguments>
    </virtualType>

If it is indicated in di.xml of my own module

<virtualType name="bodyRenderPool" type="Magento\Framework\View\Layout\ReaderPool">
    <arguments>
        <argument name="readers" xsi:type="array">
            <item name="customEl" xsi:type="string">Company\MyModule\View\Layout\Reader\Customel</item>
        </argument>
    </arguments>
</virtualType>

That array is overridden.
How to add just an element in readers array?

Gooody
  • 41
  • 1
  • 6

1 Answers1

3

Your mistake maybe in scope of di.xml

It can have a three scopes:

etc/di.xml
etc/frontend/di.xml
etc/adminhtml/di.xml

Make sure that your di.xml and di.xml you want to overwrite has the same scope.

In you case you maybe put di.xml to frontend scope and magento prefers use your di.xml that merge it.

user854029
  • 171
  • 4
  • 1
    I had the same issue as OP. Specifically was modifying the array of fields that get copied from `sales_order` to `sales_order_grid`, and the array was being overridden instead of added to. As you suggested, the scope of `di.xml` was the problem/solution. Thanks! – cyk Feb 03 '17 at 22:01
  • It can be applied to `Magento\Catalog\Model\Layer\Resolver` to add layer to `layersPool` – Christophe Ferreboeuf Feb 18 '22 at 11:28