I want to Show Static CMS block in Magento 2 html file.

  • Let me know if still not working. Commented Jul 31, 2020 at 6:55
  • No it still doesn't work @RohanHapani
    – Prits
    Commented Jul 31, 2020 at 7:31

1 Answer 1


Replace your di.xml with below code :

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

<type name="Magento\Checkout\Model\CompositeConfigProvider">
        <argument name="configProviders" xsi:type="array">
            <item name="reg_custom_checkout_block" xsi:type="object">Reg\Checkout\Model\ConfigProvider</item>

Update your getConfig() function from this below code :

namespace Reg\Checkout\Model;

use Magento\Checkout\Model\ConfigProviderInterface;
use Magento\Framework\View\LayoutInterface;

class ConfigProvider implements ConfigProviderInterface
/** @var LayoutInterface  */
protected $_layout;
protected $cmsBlock;

public function __construct(LayoutInterface $layout, $blockId)
    $this->_layout = $layout;
    $this->cmsBlock = $this->constructBlock($blockId);

public function constructBlock($blockId){
    $block = $this->_layout->createBlock('Magento\Cms\Block\Block')
    return $block;

public function getConfig()
    $config = [];
    $config['myCustomData'] = $this->constructBlock('your-block-id');

    return $config;

inside knockout js

var customData = window.checkoutConfig.myCustomData;
  • I have updated both files di.xml and Model file but doesn't get success. Where to put knockout.js part as such not created ant file @Rohan
    – Prits
    Commented Jul 31, 2020 at 7:32
  • as you mention js file in question. you can use this inside js file. Commented Jul 31, 2020 at 7:38
  • will i add this in cms-block.js file or any other file will you please help because it show my block in my step three or anything i am not getting .@Rohan
    – Prits
    Commented Jul 31, 2020 at 7:41
  • Yes. You can add in cms-block.js Commented Jul 31, 2020 at 7:42
  • I have added that under initialize function in cms-block.js. but it shows undefined customData in console.@Rohan
    – Prits
    Commented Jul 31, 2020 at 7:51

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.