Hello Magento Friends,

In today’s blog, we will learn How to Get CMS Block Collection in Magento 2.

One of the key features of Magento 2 is the Content Management System (CMS), which enables you to create and manage static content such as pages and blocks. In this blog post, we will focus on how to retrieve a collection of CMS blocks in Magento 2 programmatically.

Before starting with obtaining CMS blocks collection, check out the below links

Let’s jump into the steps to get CMS block collection in Magento 2.

Steps to Get CMS Block Collection in Magento 2:

Step 1: Create a CmsBlockcollection.php file inside the Block folder.

app\code\Vendor\Extension\Block

Now add the code as follows.

Step 2: Now, get all CMS block collection in phtml file using the below code.

Conclusion:

This way, you can retrieve CMS block collection in Magento 2. If you have any doubt, let me know through the comment box. Share the tutorial with your friends and stay in touch with us.

Happy Coding!

Click to rate this post!
[Total: 0 Average: 0]