I am creating a custom module in magento 2.4 for admin grid. Tried everything but on grid page getting below error -
Type Error occurred when creating object:
Vendor\Module\Model\ResourceModel\Grid\Collection\Interceptor, Argument 5 passed to
Vendor\Module\Model\ResourceModel\Grid\Collection\Interceptor::__construct() must implement interface
Magento\Framework\DB\Adapter\AdapterInterface or be null, string given, called in
/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php on line 121
My Collection.php
is as below -
<?php
namespace Vendor\Module\Model\ResourceModel\Grid;
class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
{
protected function _construct() {
$this->_init('Vendor\Module\Model\Grid', 'Vendor\Module\Model\ResourceModel\Grid');
}
/**
* @param \Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory
* @param \Psr\Log\LoggerInterface $logger
* @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy
* @param \Magento\Framework\Event\ManagerInterface $eventManager
* @param \Magento\Framework\DB\Adapter\AdapterInterface $connection
* @param \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource
*/
public function __construct(
\Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory,
\Psr\Log\LoggerInterface $logger,
\Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy,
\Magento\Framework\Event\ManagerInterface $eventManager,
\Magento\Framework\DB\Adapter\AdapterInterface $connection = null,
\Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource = null
) {
parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection);
}
}
What should I change in Collection.php
?