How to Get Static Block Content in Block File in Magento 2

Get Static Block Content in Block File in Magento 2

CMS blocks help to manipulate content of the Magento 2 stores. Static blocks can carry a simple text or html, CSS, Javascript to display content. It makes the reuse of the content in a modular and manageable way.

Previously, I had come up with the solution to Call CMS Static Block in Phtml File in Magento 2. Today, I will help you get static block content in block file in Magento 2.

Steps to Get Static Block Content in Block File in Magento 2:

  1. Create Index.php file at Vendor\Extension\Block folder
     
  2. Write below code to get cmsBlock data in your phtml file
     

Simply following the above steps will help you get static block content in Magento 2 block file.

Don’t forget to share your idea on how you implemented the above code. Also, if you stuck somewhere, let me know your doubt through the comment section below and I would be happy to help

Happy Coding 🙂

Get Weekly Updates

Never miss Magento tips, tricks, tutorials, and news.

Thank you for subscribing.

Something went wrong.

5
(based on 7 Reviews)

Sanjay is a co-founder at Meetanshi. He is a Certified Magento Developer who loves creating Magento E-commerce solutions. Owing to his contributions in Magento Forums and posting solutions, he is among the top 50 contributors of the Magento community in 2019. When he is not engrossed with anything related to Magento, he loves to play cricket.

Leave a reply:

Your email address will not be published.