не удалось устранить ошибку в magento2
Мне нужно решить эту ошибку ниже,
Неустранимая ошибка: Метод Magento\Ui\TemplateEngine\Xhtml\Результат::__toString()не должен вызывать исключение, пойманный тип ошибки: Аргумент 1 передан Webkul\Pos\Модель\Модель ресурсов\Агент\Коллекция::__конструкция() должна быть экземпляром Magento\Framework\DataObject\Copy\Config, экземпляром Magento\Framework\Data\Collection\EntityFactory, заданным, вызываемым в /var/www/sqdelivery/app/code/Webkul/Pos/Model/ResourceModel/Agent/Grid/Collection.php на линии 50 в /var/www/sqdelivery/vendor/magento/module-ui/Component/Wrapper/UiComponent.php в строке 0
Мой файл коллекции приведен ниже.
<?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;
}
}
Я не знаю, почему это происходит.. пожалуйста, попросите меня устранить эту ошибку Заранее Спасибо
1 answers
Попробуйте это:
namespace Webkul\Pos\Model\ResourceModel\Agent;
use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
use Magento\Framework\Data\Collection\Db\FetchStrategyInterface;
use Magento\Framework\Data\Collection\EntityFactory;
use Magento\Framework\DB\Adapter\AdapterInterface;
use Magento\Framework\Event\ManagerInterface;
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
use Magento\Framework\DataObject\Copy\Config;
use Psr\Log\LoggerInterface;
class Collection extends AbstractCollection {
protected $_idFieldName = "id";
protected $_fieldsetConfig;
/**
* @param EntityFactory $entityFactory
* @param LoggerInterface $logger
* @param FetchStrategyInterface $fetchStrategy
* @param ManagerInterface $eventManager
* @param Config $fieldsetConfig
* @param mixed $connection
* @param AbstractDb $resource
*/
public function __construct(
EntityFactory $entityFactory,
LoggerInterface $logger,
FetchStrategyInterface $fetchStrategy,
ManagerInterface $eventManager,
Config $fieldsetConfig,
AdapterInterface $connection = null,
AbstractDb $resource = null
) {
$this->_fieldsetConfig = $fieldsetConfig;
parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource);
}
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;
}
}