Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Mage::helper()
 
westymatt
Jr. Member
 
Total Posts:  4
Joined:  2008-05-22
 

What is Mage::helper() exactly?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Adam_Shuy
Member
 
Avatar
Total Posts:  51
Joined:  2008-02-20
San Jose, CA
 

I have the same question.
Please have some expert answer this question.

Problem solved.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Unirgy
Guru
 
Avatar
Total Posts:  478
Joined:  2007-09-07
 

<?php
$helper 
Mage::helper('core'); 
// $helper instanceof Mage_Core_Helper_Data

$helper Mage::helper('catalog/product_compare');
// $helper instanceof Mage_Catalog_Helper_Product_Compare
 
Magento Community Magento Community
Magento Community
Magento Community
 
Algiasa
Jr. Member
 
Total Posts:  12
Joined:  2009-01-19
 

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.

 
Magento Community Magento Community
Magento Community
Magento Community
 
MI
Sr. Member
 
Total Posts:  172
Joined:  2008-12-11
Spain
 

Thanks so much!

Now I have things more clear… but still I have one more doubt about translator function “__()”

I have:
Mage::helper(’actualidad’)->__(’Title’)
Mage::helper(’actualidad’)->__(’Status’)

and I need translate the texts “Title” and “Status” to spanish. So I have created a new file Mage_Actualidad.csv. The problem is that I see the translated text “Title” but I can’t translate “Status”
why?? I don´t understand. They are similar.

Is it possible that the text “Status” appears in other csv file with greater priority and so I must translate that other file?

(sorry for my poor english)

Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top