Trying to develop something in magento 2. But, I didn't find how to call a Helper method in template(.phtml) file.
I want a replacement of below code:
$this->helper('modulename/helpername')->methodname();
If anyone knows please help me.
helpermagento2phtml
Trying to develop something in magento 2. But, I didn't find how to call a Helper method in template(.phtml) file.
I want a replacement of below code:
$this->helper('modulename/helpername')->methodname();
If anyone knows please help me.
Best Answer
You should not use helper calls directly in the template.
Have your helper instance provided as a dependency to the block that renders the template and create a method in your block that calls the helper and call that method in the template.
Have your block defined like this
Then you can call in your template
$block->doSomething()