After I created some product in magento backend, there is an error.
Method Magento\Ui\TemplateEngine\Xhtml\Result::__toString() must not throw an exception, caught Error: Call to undefined method Magento\Framework\Data\Collection::__sleep() in /var/www/vhosts/plchk/vendor/magento/module-ui/Component/Wrapper/UiComponent.php on line 0
By searching the net, I found Magento 2 Impossible To Trace Admin Grid Error: Fatal error: Method Magento\Ui\TemplateEngine\Xhtml\Result::__toString() must not throw an exception.
Using this method, I found that the 'product.form.configurable.matrix' is the cause of problem.
I changed
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;
}
to
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
]
]);
if($childName != 'product.form.configurable.matrix'){
$this->component->addComponent('block_' . $childName, $wrapper);
} else {
}
//var_dump($childName);
}
}
$result = $this->component->render();
return (string) $result;
}
Now, I can load the admin/product/edit page but I cannot save the product. Anyone got a solution?