I'm trying to render a CMS Block, to pass rendered HTML to jsLayout, on updater

I have two CMS blocks, with same name, but for different store fronts (based on store front, the language is different).

Currently trying to get the HTML of the block, firstly tried $layoutInterface->renderElement and $layoutInterface->getBlock('block.name')->toHtml(), but without result, on first case it returns empty string, on second case it throws an exception that I'm trying to use ->toHtml on a boolean.

Following this: Get content of CMS block by identifier

I was able to get the block's HTML, but it returns me a block for a different store front. I would like to avoid messing with storefronts manually, but stuck right now and seeking for a better solution.

Would be grateful for any suggestions of how to get the right HTML of CMS block!

  • Please add additional information. How you declare block.name in yout? Is it custom block or \Magento\Cms\Block\Block? When are you try to receive block content and what is store scope for? Jun 9, 2022 at 21:00

1 Answer 1


So, thankfully to https://github.com/maksymz, I understood why the LayoutInterface::renderElement() were failing.

The block that I were importing in the layout, were a child of another block, instead of being a direct child of a container. That way, it wasn't loaded in the repository of all blocks and therefore it wasn't visible to be imported by name.

Moving the block directly to the container, fixed the issue.

One note, the block sequence is important, for some reason, if container has two blocks, then only the first block is visible, meanwhile the second isn't available in LayoutInterface::getBlock() method and will result in false.

Magento version 2.4.3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.