For example:

$helper = Mage::helper('pricegrabber');

Please note that described above is actually equivalent to:

$helper = Mage::helper('pricegrabber/data');

Helper “data” is called by the default. Templates contain the design, with which can potentially work designer or even the website owner. Therefore, the template should be clear to those people who use Magento helpers. For example:

<a href="<?php echo $this->helper('cart')->getUrl(); ?>">Cart</a>

There is a question: why this method is not placed in the block that is responsible for displaying the the cart. The answer is pretty simple: this method can be used not only in this template. For example, you want make a link to the shopping cart on the Home page. Then you need just to call a method of the helper in the right place. So Magento helper: 1. makes the code of templates more elegant 2. allows to use the functions in different templates Magento helpers can also be used in controllers, blocks and even models, because helper has built-in function for multilanguage support. For example:

$text = $this->helper('dailydeals')->getDealsConfig('dailydeals_group/label_deals_link');

Depending on the choice of the language translation may vary. The search of the phrase will be in the file for the localization for the module (in our example - "checkout"). If the translation will be not found, the phrase in brackets will be used.

Create your own Magento helper

Let’s create helper that will return us variable multiplied by two. At first you should declare Magento helper in config.xml. We do this in tag <global> after tag </ blocks>.


Then you should create a folder and file app/code/local/Test/Helper/Data.php, which contains the function getNextDayNameWithNumber($nextDayNumber, 'next') that returns a date  and days of week by order days. Helper - an object that extends the base class Mage_Core_Helper_Abstract.

class Webinse_DailyDeals_Helper_Data extends Mage_Core_Helper_Abstract{
    public function getNextDayNameWithNumber($nextDayNumber, $next){
       $nextDayName = date('l', strtotime("Sunday + " . (int)$nextDayNumber . " Days"));
       $result = array(
                 'name' => $nextDayName,
                 'date' => date("Y-m-d", strtotime('next' . $nextDayName))
       return $result;

Congrats! Now you know almost everything about Magento helper and you can create it yourself!