Magento Pagebuilder Block error
While experimenting with Magento's Pagebuilder component, I run into an error when I was trying to configure a block widget I added to the page.
Whilst the PageBuilder UI only showed a generic error message, Magento's debug.log revealed the following error:
main.ERROR: Warning: Undefined array key "default" in /var/www/html/vendor/magento/module-page-builder/Model/Stage/RendererPool.php on line 47 [] []
Debugging the issue by adding some error_log()
output showed that the RendererPool tried to find a renderer for the
block, but could not find it. Additionally, there does not seem to be a fallback renderer registered for the "default"
type as well.
I am not sure if there is something wrong in my local setup or if this is happens on purpose. The "fix" for this is simple,
we have to make the RendererPool aware of the block renderer. In the di.xml
file of your module add the following configuration code:
<type name="Magento\PageBuilder\Model\Stage\RendererPool">
<arguments>
<argument name="renderers" xsi:type="array">
<item name="block" xsi:type="object">Magento\PageBuilder\Model\Stage\Renderer\Block</item>
</argument>
</arguments>
</type>
In my case, I already had defined the RendererPool type in one of my modules, so I just added the block item configuration to the existing type configuration.
After that, I ran the following commands to let Magento be aware of the new configuration:
./bin/magento setup:di:compile
./bin/magento cache:clear
In my browser, I reloaded the Magento UI, opened PageBuilder again, added a block, and configured it. The error is gone now.