I had an error like below,
Fatal error: Uncaught TypeError: Argument 5 passed to
Webkul\Pos\Model\ResourceModel\Agent\Collection::__construct() must be
an instance of Magento\Framework\App\ResourceConnection, null given,
called in
/var/www/sqdelivery/generated/code/Webkul/Pos/Model/ResourceModel/Agent/Collection/Interceptor.php on line 14 and defined in
/var/www/sqdelivery/app/code/Webkul/Pos/Model/ResourceModel/Agent/Collection.php:31 Stack trace: #0
/var/www/sqdelivery/generated/code/Webkul/Pos/Model/ResourceModel/Agent/Collection/Interceptor.php(14):
Webkul\Pos\Model\ResourceModel\Agent\Collection->__construct(Object(Magento\Framework\Data\Collection\EntityFactory), Object(Magento\Framework\Logger\Monolog),
Object(Magento\Framework\Data\Collection\Db\FetchStrategy\Query),
Object(Magento\Framework\Event\Manager\Proxy), NULL, NULL) #1
/var/www/sqdelivery/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(111):
Webkul\Pos\Model\ResourceModel\Agent\Collection\Interceptor->__construct(Object(Magento\Framework\Data\Collection\EntityFac
in
**/var/www/sqdelivery/app/code/Webkul/Pos/Model/ResourceModel/Agent/Collection.php
on line 31**
what is does means.?? My Collection file code is below,
<?php
namespace Webkul\Pos\Model\ResourceModel\Agent;
use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
class Collection extends AbstractCollection {
const AGENT_MODEL_NAME = Webkul\Pos\Model\Agent::class;
/**
* @var \Magento\Framework\DataObject\Copy\Config
*/
protected $_fieldsetConfig;
/**
* @var string
*/
protected $_modelName;
public function __construct(
\Magento\Framework\Data\Collection\EntityFactory $entityFactory,
\Psr\Log\LoggerInterface $logger,
\Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy,
\Magento\Framework\Event\ManagerInterface $eventManager,
\Magento\Framework\App\ResourceConnection $resource,
\Magento\Framework\Validator\UniversalFactory $universalFactory,
\Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot $entitySnapshot,
\Magento\Framework\DataObject\Copy\Config $fieldsetConfig,
\Magento\Framework\DB\Adapter\AdapterInterface $connection = null,
$modelName = self::AGENT_MODEL_NAME
) {
$this->_fieldsetConfig = $fieldsetConfig;
$this->_modelName = $modelName;
parent::__construct(
$entityFactory,
$logger,
$fetchStrategy,
$eventManager,
$eavConfig,
$resource,
$eavEntityFactory,
$resourceHelper,
$universalFactory,
$entitySnapshot,
$connection
);
}
protected $_idFieldName = "id";
protected function _construct() {
$this->_init("Webkul\Pos\Model\Agent", "Webkul\Pos\Model\ResourceModel\Agent");
$this->_map["fields"]["id"] = "main_table.id";
}
public function setAgentData($condition, $attributeData) {
return $this->getConnection()->update($this->getTable("pos_agent"), $attributeData, $where = $condition);
}
public function addNameToSelect()
{
$fields = [];
$agentAccount = $this->_fieldsetConfig->getFieldset('agent_account');
print_r($agentAccount);
exit;
foreach ($agentAccount as $code => $field) {
if (isset($field['email'])) {
$fields[$code] = $code;
}
}
$connection = $this->getConnection();
$concatenate = [];
if (isset($fields['prefix'])) {
$concatenate[] = $connection->getCheckSql(
'{{prefix}} IS NOT NULL AND {{prefix}} != \'\'',
$connection->getConcatSql(['LTRIM(RTRIM({{prefix}}))', '\' \'']),
'\'\''
);
}
$concatenate[] = 'LTRIM(RTRIM({{firstname}}))';
$concatenate[] = '\' \'';
if (isset($fields['middlename'])) {
$concatenate[] = $connection->getCheckSql(
'{{middlename}} IS NOT NULL AND {{middlename}} != \'\'',
$connection->getConcatSql(['LTRIM(RTRIM({{middlename}}))', '\' \'']),
'\'\''
);
}
$concatenate[] = 'LTRIM(RTRIM({{lastname}}))';
if (isset($fields['suffix'])) {
$concatenate[] = $connection->getCheckSql(
'{{suffix}} IS NOT NULL AND {{suffix}} != \'\'',
$connection->getConcatSql(['\' \'', 'LTRIM(RTRIM({{suffix}}))']),
'\'\''
);
}
$nameExpr = $connection->getConcatSql($concatenate);
$this->addExpressionAttributeToSelect('name', $nameExpr, $fields);
return $this;
}
public function getSelectCountSql()
{
$select = parent::getSelectCountSql();
$select->resetJoinLeft();
return $select;
}
/**
* Reset left join
*
* @param int $limit
* @param int $offset
* @return \Magento\Eav\Model\Entity\Collection\AbstractCollection
*/
protected function _getAllIdsSelect($limit = null, $offset = null)
{
$idsSelect = parent::_getAllIdsSelect($limit, $offset);
$idsSelect->resetJoinLeft();
return $idsSelect;
}
}
Anyone please help me to slove this error. Thanks in advance.
bin/magento setup:upgrade
after finished edit your construct class