Q: Magento 2 : Custom Module Admin Grid is not Showing My Custom module is working in Magento 2.4.0 but when I installed in Magento 2.4.3 version it's showing below error in grid section.
Type Error occurred when creating object: Rh\CategoryGallery\Model\ResourceModel\Imagegallery\Collection\Interceptor, Argument 5 passed to Rh\CategoryGallery\Model\ResourceModel\Imagegallery\Collection\Interceptor::__construct() must implement interface Magento\Framework\DB\Adapter\AdapterInterface or be null, array given, called in /var/www/html/cwcabinets/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php on line 121
Exception in /var/www/html/m2/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:131

Here is my code
    Rh/CategoryGallery/Model/ResourceModel/Imagegallery/Collection.php
 <?php
namespace Rh\CategoryGallery\Model\ResourceModel\Imagegallery;

/**
 * Class Collection
 * @package Rh\CategoryGallery\Model\ResourceModel\Imagegallery
 */
class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
{
    /**
     * Define resource model
     *
     * @return void
     */
    protected function _construct()
    {
        $this->_init('Rh\CategoryGallery\Model\Imagegallery', 'Rh\CategoryGallery\Model\ResourceModel\Imagegallery');
    }
}


app/code/Rh/CategoryGallery/Model/ResourceModel/Imagegallery.php

<?php
namespace Rh\CategoryGallery\Model\ResourceModel;

/**
 * Class Imagegallery
 * @package Rh\CategoryGallery\Model\ResourceModel
 */
class Imagegallery extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
{
    /**
     * Imagegallery constructor.
     * @param \Magento\Framework\Model\ResourceModel\Db\Context $context
     */
    public function __construct(
        \Magento\Framework\Model\ResourceModel\Db\Context $context
    ) {
        parent::__construct($context);
    }

    /**
     * init category gallory
     */
    protected function _construct()
    {
        $this->_init('categorygallery', 'gallery_id');
    }
}

app/code/Rh/CategoryGallery/etc/di.xml

<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="category_image_gallery_listing_data_source" xsi:type="string">Rh\CategoryGallery\Model\ResourceModel\Imagegallery\Collection</item>
            </argument>
        </arguments>
    </type>
    <virtualType name="Rh\CategoryGallery\Model\ResourceModel\Imagegallery\Collection" type="Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult">
        <arguments>
            <argument name="mainTable" xsi:type="string">categorygallery</argument>
            <argument name="resourceModel" xsi:type="string">Rh\CategoryGallery\Model\ResourceModel\Imagegallery</argument>
        </arguments>
    </virtualType>
    <type name="Rh\CategoryGallery\Model\ImageUploader">
        <arguments>
        <argument name="baseTmpPath" xsi:type="string">categoryimagegallery/tmp/</argument>
        <argument name="basePath" xsi:type="string">categoryimagegallery/</argument>
        <argument name="allowedExtensions" xsi:type="array">
            <item name="jpg" xsi:type="string">jpg</item>
            <item name="jpeg" xsi:type="string">jpeg</item>
            <item name="gif" xsi:type="string">gif</item>
            <item name="png" xsi:type="string">png</item>
        </argument>
        </arguments>
    </type>
</config>

Let me know What I need to change for Magento 2.4.3


A: I resolved my issue. I found the solution in this link Type Error occurred when creating Interceptor after Updating to 2.3.2
Here is my changed Di.xml file
<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="category_image_gallery_listing_data_source" xsi:type="string">Rh\CategoryGallery\Model\ResourceModel\Imagegallery\Imagegallery\Collection</item>
            </argument>
        </arguments>
    </type>
    <virtualType name="Rh\CategoryGallery\Model\ResourceModel\Imagegallery\Imagegallery\Collection" type="Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult">
        <arguments>
            <argument name="mainTable" xsi:type="string">categorygallery</argument>
            <argument name="resourceModel" xsi:type="string">Rh\CategoryGallery\Model\ResourceModel\Imagegallery</argument>
        </arguments>
    </virtualType>
    <type name="Rh\CategoryGallery\Model\ImageUploader">
        <arguments>
        <argument name="baseTmpPath" xsi:type="string">categoryimagegallery/tmp/</argument>
        <argument name="basePath" xsi:type="string">categoryimagegallery/</argument>
        <argument name="allowedExtensions" xsi:type="array">
            <item name="jpg" xsi:type="string">jpg</item>
            <item name="jpeg" xsi:type="string">jpeg</item>
            <item name="gif" xsi:type="string">gif</item>
            <item name="png" xsi:type="string">png</item>
        </argument>
        </arguments>
    </type>
</config>

Also this link help to me
https://www.hungersoft.com/info/not-a-registered-handle-data-source-magento2-admin-grid

A: Change the ResourceModel Code File as Below :

app/code/Rh/CategoryGallery/Model/ResourceModel/Imagegallery.php

<?php
namespace Rh\CategoryGallery\Model\ResourceModel;

/**
 * Class Imagegallery
 * @package Rh\CategoryGallery\Model\ResourceModel
 */
class Imagegallery extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
{
    /**
     * init category gallery
     */
    public function _construct()
    {
        $this->_init('categorygallery', 'gallery_id');
    }
}

Change Collection File as :

Rh/CategoryGallery/Model/ResourceModel/Imagegallery/Collection.php

    <?php
    namespace Rh\CategoryGallery\Model\ResourceModel\Imagegallery;
    
    /**
     * Class Collection
     * @package Rh\CategoryGallery\Model\ResourceModel\Imagegallery
     */
    class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
    {
        /**
         * Define resource model
         *
         * @return void
         */
        public function _construct()
        {
            $this->_init('Rh\CategoryGallery\Model\Imagegallery', 'Rh\CategoryGallery\Model\ResourceModel\Imagegallery');
            $this->_setIdFieldName('gallery_id');
        }
    }

And then run the Following commands in sequence :
rm -rf generated/*
rm -rf var/cache/*
php bin/magento setup:di:compile
php bin/magento cache:flush

Reload the Page again.
Also my recomendation is to use the ui_component listing and the DataProvider, It will be best Method.
The Above method is very old.
