Here one issue in my magento 2.1. I create one di.xml file for my own module but i got error in cms page and static block. Check below image for cms page and static block error.
CMS Page:- enter image description here
Static Block:- enter image description here
And Below my di.xml code for admin panel. (Job/Test/etc/adminhtml/di.xml)
<?xml version="1.0"?>
<!--
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<virtualType name="Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Pool" type="Magento\Ui\DataProvider\Modifier\Pool">
<arguments>
<argument name="modifiers" xsi:type="array">
<item name="testtab" xsi:type="array">
<item name="class" xsi:type="string">Job\Test\Ui\Component\DataProvider\Product\Modifier\Testtab</item>
<item name="sortOrder" xsi:type="number">200</item>
</item>
</argument>
</arguments>
</virtualType>
<type name="Job\Test\Ui\Component\DataProvider\Product\Modifier\Testtab">
<arguments>
<argument name="scopeName" xsi:type="string">product_form.product_form</argument>
</arguments>
</type>
<type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
<arguments>
<argument name="collections" xsi:type="array">
<item name="testtab_test_listing_data_source" xsi:type="string">Job\Test\Model\ResourceModel\Test\Grid\Collection</item>
<item name="demo_index_grid_data_source" xsi:type="string">Job\Test\Model\ResourceModel\Test\Grid\Collection</item>
</argument>
</arguments>
</type>
</config>
2 Answers 2
Grid di.xml is global. So when you create your custom module admin grid, your di.xml should be under etc folder, not etc/adminhtml. So
Move Job/Test/etc/adminhtml/di.xml to Job/Test/etc/di.xml
-
Sohel, now one issue create when i move Job/Test/etc/adminhtml/di.xml to Job/Test/etc/di.xml in my custom module. I create one tab in admin catalog product page. Now this tab is disappear.Payal Patel– Payal Patel2016年08月19日 10:39:54 +00:00Commented Aug 19, 2016 at 10:39
-
You move only grid related code. So you need to create two di.xml one under etc and other etc/adminhtml. So your tab related code move to etc/adminhtml/di.xml only.Sohel Rana– Sohel Rana2016年08月19日 10:47:24 +00:00Commented Aug 19, 2016 at 10:47
-
Hey Sohel, my issue solve by me for above code. Now both are working perfect. And Thank for your helpPayal Patel– Payal Patel2016年08月19日 10:50:15 +00:00Commented Aug 19, 2016 at 10:50
I try below code and my issue solved.
Job/Test/etc/adminhtml/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<virtualType name="Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Pool" type="Magento\Ui\DataProvider\Modifier\Pool">
<arguments>
<argument name="modifiers" xsi:type="array">
<item name="testtab" xsi:type="array">
<item name="class" xsi:type="string">Job\Test\Ui\Component\DataProvider\Product\Modifier\Testtab</item>
<item name="sortOrder" xsi:type="number">1000</item>
</item>
</argument>
</arguments>
</virtualType>
<type name="Job\Test\Ui\Component\DataProvider\Product\Modifier\Testtab">
<arguments>
<argument name="scopeName" xsi:type="string">product_form.product_form</argument>
</arguments>
</type>
</config>
Job/Test/etc/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
<arguments>
<argument name="collections" xsi:type="array">
<item name="testtab_test_listing_data_source" xsi:type="string">Job\Test\Model\ResourceModel\Test\Grid\Collection</item>
<item name="demo_index_grid_data_source" xsi:type="string">Job\Test\Model\ResourceModel\Test\Grid\Collection</item>
</argument>
</arguments>
</type>
</config>
Explore related questions
See similar questions with these tags.