Skip to content

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

September 17, 2011

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:


From → Module building

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: