Magento Block has no getters and setters

I finally realise Block class in Magento is not like Model class – it has no getters and setters.

It breaks MVC logic if we want to set data in Block, that’s why Block has no setters. However, when Block makes a variable which can be used in template. It is a maker, not a setter. So the function name is usually getSomething(). From the pointer view of template, it is ‘get’, but it is not a getter for Block.

Magento could name this kind of function in Block something else for people easy to understand.

Leave a Reply

Your email address will not be published. Required fields are marked *