Magento – Magento 2: Setup Upgrade Error

gridmagento2setup-upgrade

In custom module, I have two grids. After installing module, When I use the upgrade command "sudo php bin/magento setup:upgrade".

I got an error like this.

 Uncaught Magento\Framework\Exception\LocalizedException: More than one node matching the query: /config/type[@name='Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory']

Help me to solve this issue.

This is my Vendor/Module/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">


    <virtualType name="RespbannersliderGridFilterPool" type="Magento\Framework\View\Element\UiComponent\DataProvider\FilterPool">
        <arguments>
            <argument name="appliers" xsi:type="array">
                <item name="regular" xsi:type="object">Magento\Framework\View\Element\UiComponent\DataProvider\RegularFilter</item>
                <item name="fulltext" xsi:type="object">Magento\Framework\View\Element\UiComponent\DataProvider\FulltextFilter</item>
            </argument>
        </arguments>
    </virtualType>

    <virtualType name="RespbannersliderGridDataProvider" type="Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider">
        <arguments>
            <argument name="collection" xsi:type="object" shared="false">Vendor\Module\Model\ResourceModel\Respbannerslider</argument>
            <argument name="filterPool" xsi:type="object" shared="false">RespbannersliderGridFilterPool</argument>
        </arguments>
    </virtualType>

    <type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
        <arguments>
            <argument name="collections" xsi:type="array">
                <item name="respbannerslider_data_source" xsi:type="string">Vendor\Module\Model\ResourceModel\Respbannerslider\Grid\Collection</item>
            </argument>
       </arguments>
    </type>
    <type name="Vendor\Module\Model\ResourceModel\Respbannerslider\Grid\Collection">
        <arguments>
            <argument name="mainTable" xsi:type="string">cartin24_respslidemaster</argument>
            <argument name="eventPrefix" xsi:type="string">respbannerslider_collection</argument>
            <argument name="eventObject" xsi:type="string">respbannerslider_collection</argument>
            <argument name="resourceModel" xsi:type="string">Vendor\Module\Model\ResourceModel\Respbannerslider</argument>
        </arguments>
    </type>


    <virtualType name="SlideGridFilterPool" type="Magento\Framework\View\Element\UiComponent\DataProvider\FilterPool">
        <arguments>
            <argument name="appliers" xsi:type="array">
                <item name="regular" xsi:type="object">Magento\Framework\View\Element\UiComponent\DataProvider\RegularFilter</item>
                <item name="fulltext" xsi:type="object">Magento\Framework\View\Element\UiComponent\DataProvider\FulltextFilter</item>
            </argument>
        </arguments>
    </virtualType>


    <virtualType name="SlideGridDataProvider" type="Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider">
        <arguments>
            <argument name="collection" xsi:type="object" shared="false">Vendor\Module\Model\ResourceModel\Slide</argument>
            <argument name="filterPool" xsi:type="object" shared="false">SlideGridFilterPool</argument>
        </arguments>
    </virtualType>

    <type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
        <arguments>
            <argument name="collections" xsi:type="array">
                <item name="slide_data_source" xsi:type="string">Vendor\Module\Model\ResourceModel\Slide\Grid\Collection</item>
            </argument>
       </arguments>
    </type>

   <type name="Vendor\Module\Model\ResourceModel\Slide\Grid\Collection">
        <arguments>
            <argument name="mainTable" xsi:type="string">cartin24_respbannerslider</argument>
            <argument name="eventPrefix" xsi:type="string">slide_collection</argument>
            <argument name="eventObject" xsi:type="string">slide_collection</argument>
            <argument name="resourceModel" xsi:type="string">Vendor\Module\Model\ResourceModel\Slide</argument>
        </arguments>
   </type>
</config>

Best Answer

Collection class is missing in collection argument

See Below Code

your Code:

<virtualType name="RespbannersliderGridDataProvider" type="Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider">
        <arguments>
            <argument name="collection" xsi:type="object" shared="false">Vendor\Module\Model\ResourceModel\Respbannerslider</argument>
            <argument name="filterPool" xsi:type="object" shared="false">RespbannersliderGridFilterPool</argument>
        </arguments>
    </virtualType>

Require changes :

<virtualType name="RespbannersliderGridDataProvider" type="Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider">
        <arguments>
            <argument name="collection" xsi:type="object" shared="false">Vendor\Module\Model\ResourceModel\Respbannerslider\Collection</argument>
            <argument name="filterPool" xsi:type="object" shared="false">RespbannersliderGridFilterPool</argument>
        </arguments>
    </virtualType>