Magento2

How to call any block function in phtml file Magento 2?

How to call any block function in phtml Magento 2?

If you are inside a phtml file, and you need to call an specific function inside another block. You can do the following :

Step 1 : Create Block file

File Path : app/code/V4U/Helloworld/Block/View.php

Step 2 : Create template file

File Path : app/code/V4U/Helloworld/view/frontend/templates/view.phtml

In another phtml you can call by following way.

Step 3: Run the following Magento command :

php bin/magento cache:clean

🙂 Happy Coding. Keep Liking & Sharing 💻

Tagged ,