Skip to content

Magneto 2.4.1 Collection: __construct() must implement interface MagentoFrameworkDBAdapterAdapterInterface

I have a custom module with a few tables. I have the model, resource model and collection classes in place. If I try to access the contents of the table, I am getting this error

Type Error occurred when creating object: VendorModuleModelResourceModelAddressGroupsCollectionInterceptor, Argument 5 passed to VendorModuleModelResourceModelAddressGroupsCollectionInterceptor::__construct() must implement interface MagentoFrameworkDBAdapterAdapterInterface or be null, string given, called in /home/user/magentoTest/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php on line 121

I’m getting this error only in production mode. If I switch to developer mode, everything seems to be working fine.

This is my collection.php

<?php
namespace VendorModuleModelResourceModelAddressGroups;

class Collection extends MagentoFrameworkModelResourceModelDbCollectionAbstractCollection{

    public function _construct(){
        $this->_init('VendorModuleModelAddressGroups', 'VendorModuleModelResourceModelAddressGroups');
    }
}