After a magento update was made from version 2.3.5 to 2.4.7, an error in my custom module started appearing in the administrator. In the main view inside the administrator shows me the following error:
Type Error occurred when creating object: G4AMainSliderModelResourceModelMainSliderGridCollectionInterceptor, G4AMainSliderModelResourceModelMainSliderGridCollectionInterceptor::__construct(): Argument #5 ($connection) must be of type ?MagentoFrameworkDBAdapterAdapterInterface, string given, called in /opt/bitnami/apache/htdocs/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php on line 121 Exception in /opt/bitnami/apache/htdocs/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:131
Collection.php
namespace G4AMainSliderModelResourceModelMainSliderGrid; use MagentoFrameworkModelResourceModelDbCollectionAbstractCollection; class Collection extends AbstractCollection { protected $_idFieldName = 'slide_id'; public function _construct() { $this->_init('G4AMainSliderModelMainSliderGrid', 'G4AMainSliderModelResourceModelMainSliderGrid'); } }
di.xml
<type name='MagentoFrameworkViewElementUiComponentDataProviderCollectionFactory'>
<arguments>
<argument name="collections" xsi:type="array">
<item name="infra_main_slider_listing_data_source" xsi:type="string">G4AMainSliderModelResourceModelMainSliderGridCollection</item>
</argument>
</arguments>
</type>
<virtualType name="G4AMainSliderModelResourceModelMainSliderGridCollection" type="MagentoFrameworkViewElementUiComponentDataProviderSearchResult">
<arguments>
<argument name="mainTable" xsi:type="string">infra_main_slider</argument>
<argument name="resourceModel" xsi:type="string">G4AMainSliderModelResourceModelMainSlider</argument>
</arguments>
</virtualType>
Code(constructor)generated by magento:
generated/code/G4A/MainSlider/Model/ResourceModel/MainSlider/Collection/Interceptor.php
public function __construct(MagentoFrameworkDataCollectionEntityFactoryInterface $entityFactory, PsrLogLoggerInterface $logger, MagentoFrameworkDataCollectionDbFetchStrategyInterface $fetchStrategy, MagentoFrameworkEventManagerInterface $eventManager, ?MagentoFrameworkDBAdapterAdapterInterface $connection = null, ?MagentoFrameworkModelResourceModelDbAbstractDb $resource = null) { $this->___init(); parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource); }
Magento version 2.4.7
PHP 8.3
MariaDB 11.4.3
when bin/magento di:compile command is executed the error is shown
when bin/magento setup:upgrade command is executed the error isn’t shown
The store is in developer mode
Any help is appreciated…