Magento’s objects (that inherit from Varien_Object
) have special “magic” getter and setter methods implemented with PHP’s magic __call
method. If you’ve got a Magento object, you can just set and get data like this
$this->setFooBar('a value');
echo $this->getFooBar();
without any setFooBar
or getFooBar
methods defined on your objects.
There’s been a bit of conventional wisdom floating around since 2011 that these getters and setters are going away in Magento 2. However, as of the latest preview release, they’re still in place.
Removing these magic methods would mean a lot of refactoring for extension developers, but these same magic methods are often a key contributor to the confusion a new developer has with Magento. My guess is they stay in, although with no official release date for Magento 2, anything can happen.