How to Pass Data From CMS Block to PHTML File in Magento 2

How to Pass Data From CMS Block to PHTML File in Magento 2

Magento 2 CMS is popular among the E-commerce store owners owing to its flexibility. It allows fulfilling the business requirements that are based on customer expectations or to improve the onsite user experience.

As a part of such requirement fulfilment and enriching the store frontend, the following solution to pass data from CMS block to PHTML file in Magento 2 can be helpful.

Using the below code, one can update the category on the home page to display the subcategories, display product blocks, offers launched, etc.

Method to pass data from CMS block to PHTML file in Magento 2:

Add the following code in any static block:

Create display-product.phtml in app/design/[Namespace]/[Theme]/Magento_Catalog/templates

That’s it.

Any doubts? Please mention them in the Comments section below and I’d be happy to help.

Feel free to share the solution with Magento 2 community via social media.

Thank you.

5
(based on 16 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.

SUBSCRIBE
3.8
(based on 5 Reviews)