I need to solve this below error,
Fatal error: Method Magento\Ui\TemplateEngine\Xhtml\Result::__toString() must not throw an exception, caught TypeError: Argument 1 passed to Webkul\Pos\Model\ResourceModel\Agent\Collection::__construct() must be an instance of Magento\Framework\DataObject\Copy\Config, instance of Magento\Framework\Data\Collection\EntityFactory given, called in /var/www/sqdelivery/app/code/Webkul/Pos/Model/ResourceModel/Agent/Grid/Collection.php on line 50 in /var/www/sqdelivery/vendor/magento/module-ui/Component/Wrapper/UiComponent.php on line 0
My collection file is below.
<?php
namespace Webkul\Pos\Model\ResourceModel\Agent;
use
Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
class Collection extends AbstractCollection {
protected $_idFieldName = "id";
protected $_fieldsetConfig;
public function __construct( \Magento\Framework\DataObject\Copy\Config $fieldsetConfig)
{
$this->_fieldsetConfig = $fieldsetConfig;
}
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 groupByEmail()
{
$this->getSelect()->from(
['email' => $this->getEntity()->getEntityTable()],
['email_count' => new \Zend_Db_Expr('COUNT(email.id)')]
)->where(
'email.id = e.id'
)->group(
'email.email'
);
return $this;
}
public function addNameToSelect()
{
$fields = [];
$agentAccount = $this->_fieldsetConfig->getFieldset('agent_account');
foreach ($agentAccount as $code => $field) {
if (isset($field['name'])) {
$fields[$code] = $code;
}
}
$connection = $this->getConnection();
$concatenate = [];
$concatenate[] = 'LTRIM(RTRIM({{firstname}}))';
$concatenate[] = 'LTRIM(RTRIM({{lastname}}))';
$nameExpr = $connection->getConcatSql($concatenate);
$this->addExpressionAttributeToSelect('name', $nameExpr, $fields);
return $this;
}
public function getSelectCountSql()
{
$select = parent::getSelectCountSql();
$select->resetJoinLeft();
return $select;
}
protected function _getAllIdsSelect($limit = null, $offset = null)
{
$idsSelect = parent::_getAllIdsSelect($limit, $offset);
$idsSelect->resetJoinLeft();
return $idsSelect;
}
}
I don't known why it is happening.. please hep me to resolve this error Thanks in Advance