Functions in Blocks and in Helpers: what’s the difference?

For me, it’s pretty clear when the difference between a Block and a Model. Basically, the Model defines and implements our «object» in the Magento system, so we can call it whenever we need it. Blocks let us run specific functions from a concrete part of the website (defined in the layout) and call them from the phtml files that have been loaded from the page layout using a block.

But imagine that you haven’t defined a specific block of your model in the layout of one concrete page, but you need to run a function that uses your model. The solution is using helpers. The functions defined in Helpers files can be loaded from anywhere on the phtml files, so you don’t need to create a specific block each time you need to use your model. Functions defined in Helpers can be accessed by:


Leave a Reply

Your email address will not be published.