The error you're getting is indeed triggered in vendor\magento\module-ui\Component\Wrapper\UiComponent.php
.
However, it is not triggered at line 0 but when the result is being converted to a string in the following method in the return statement:
protected function _toHtml()
{
foreach ($this->getChildNames() as $childName) {
$childBlock = $this->getLayout()->getBlock($childName);
if ($childBlock) {
$wrapper = $this->blockWrapperFactory->create([
'block' => $childBlock,
'data' => [
'name' => 'block_' . $childName
]
]);
$this->component->addComponent('block_' . $childName, $wrapper);
}
}
$result = $this->component->render();
return (string)$result;
}
Here's what you can try to debug your problem:
- check what
$result
contains before the string conversion and return statement is called
- get informations about the component that is causing an issue by calling
$component->getName()
, $component->getComponentName()
and $component->getData()
to help you finding out what the problem is
The problem is the order of the parameters in your parent::__construct()
call.
the class your are extending does not have a constructor so it the parent of the parent constructor will be called.
And this parent of parent is \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
.
It's constructor looks like this:
public function __construct(
\Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory,
\Psr\Log\LoggerInterface $logger,
\Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy,
\Magento\Framework\Event\ManagerInterface $eventManager,
\Magento\Framework\DB\Adapter\AdapterInterface $connection = null,
\Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource = null
) {
$this->_eventManager = $eventManager;
parent::__construct($entityFactory, $logger, $fetchStrategy, $connection);
$this->_construct();
$this->_resource = $resource;
$this->setConnection($this->getResource()->getConnection());
$this->_initSelect();
}
so the 5th parameter must be something that implements \Magento\Framework\DB\Adapter\AdapterInterface
.
In your case, the 5th parameter is something that implementes \Magento\Store\Model\StoreManagerInterface
.
Change your parent::__construct()
call to this:
parent::__construct(
$entityFactory,
$logger,
$fetchStrategy,
$eventManager,
$connection,
$resource
);
the parameters $storeManager
and $metadataPool
are not part of the classes you extend. If you need them in your own class you can add them in the __construct
method like this:
$this->storeManager = $storeManager;
$this->metadataPool = $metadataPool;
and declare them as protected members as you did for $aggregations
.
Best Answer
I just fixed the above mention issue which I mention in my question.
I got the error is actually coming from the Core files.
Should use $attributeCode as lines 495 & 496 rather than hardcoded ['image']
Like below code
I hope its working for you as well.