I have created a custom module and it’s working fine,if I only run php bin/magento setup:upgrade
command. However, when I attempt to run php bin/magento s:d:c
it raises an exception.
Type Error occurred when creating object: VendorModuleNameModelResourceModelPriceResultCollectionInterceptor, Argument 5 passed to VendorModuleNameModelResourceModelPriceResultCollectionInterceptor::__construct() must implement interface MagentoFrameworkDBAdapterAdapterInterface or be null, string given, called in /Users/macbook/Sites/magento243/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php on line 121
Exception in /Users/macbook/Sites/magento243/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:131
Here is my collection class
<?php
namespace VendorModuleNameModelResourceModelPriceResult;
use MagentoFrameworkModelResourceModelDbCollectionAbstractCollection;
class Collection extends AbstractCollection
{
protected $_idFieldName = 'id';
protected function _construct()
{
$this->_init(
VendorModuleNameModelPriceResult::class,
VendorModuleNameModelResourceModelPriceResult::class,
);
}
}
etc/di.xml
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<virtualType name="VendorModuleNameModelResourceModelSyncPriceResultCollection" type="MagentoFrameworkViewElementUiComponentDataProviderSearchResult">
<arguments>
<argument name="mainTable" xsi:type="string">price_result</argument>
<argument name="resourceModel" xsi:type="string">VendorModuleNameModelResourceModelSyncPriceResult</argument>
</arguments>
</virtualType>
<type name="MagentoFrameworkViewElementUiComponentDataProviderCollectionFactory">
<arguments>
<argument name="collections" xsi:type="array">
<item name="price_result_listing_data_source" xsi:type="string">VendorModuleNameModelResourceModelSyncPriceResultCollection</item>
</argument>
</arguments>
</type>
</config>