Total Posts: 12
A bit late to be answering this, but wth, I wasted hours following the code for this so I might as well spell it out for any newbie who stumbles on this post.
Mage:helper()’s purpose in life is to return a class, which inherits Mage_Core_Helper_Abstract. The actual name of that class (and by extension the folder where it resides), depends partly on the argument we provide to Mage:helper(). The steps are like so…
First we determine the namespace. The default is “Mage”. I’m still working on how to change this, so we’ll stick to “Mage for now.
‘payment’ -> Mage
‘catalog/product_compare’ -> Mage
The next part is determined by the argument. If it doesn’t contains a slash (/) the string “/data” is appended to the initial argument. Otherwise it remains as is.
Then the argument is split by ‘/’ and the first part is appended to our class name.
‘payment’ -> Mage_Payment
‘catalog/product_compare’ -> Mage_Catalog
Next we append ‘Helper’ to the class name
‘payment’ -> Mage_Payment_Helper
‘catalog/product_compare’ -> Mage_Catalog_Helper
And we finish off with the rest of the argument
‘payment’ -> Mage_Payment_Helper_Data (remember ‘/data’ was appended to ‘payment’ earlier)
‘catalog/product_compare’ -> Mage_Catalog_Helper_Product_Compare
For those that haven’t noticed, this class will be inheriting from Mage_Core_Helper_Abstract which just so happens to have the aptly named __() function, which acts as magento’s translator. This means that in our new class we have the opportunity to override this and provide our own functionality.