Magento Forum - UK Magento Forum (Unofficial)

An unofficial but dedicated Magento Forum for Magento Users, Designers and Developers

How To Create A Helper In Magento

A forum to discuss Magento development and coding

How To Create A Helper In Magento

Postby fay_khattak » Mon Aug 01, 2016 1:43 pm

Due to some good reasons, it’s a bad programming habit, and it’s not recommended at all if you modify the core files of Magento. But sometimes, you may want to add new classes or override different functions in your Magento module. Therefore, Magento came up with the Helpers that are the right entity to fulfill your needs.

A Helper in Magento is an object that contains practical methods. You can call it in template files, controllers, models or anywhere in Magento. All you need is to load your helper like this:

Mage::helper('MODULE_NAME/HELPER_CLASS')->HELPER_FUNCTION();

Creating a Helper is quite easy. In this tutorial, you will learn how to create a helper in Magento. You will also find out how to use a helper!

How To Create A Helper In Magento
Regards,
Muhammad Fayyaz Uddin Khattak,
Magento Community Manager,
Cloudways.
Twitter: https://twitter.com/fay_khattak
User avatar
fay_khattak
 
Posts: 26
Joined: Tue Jan 19, 2016 8:39 am
Location: Karachi, Pakistan

Re: How To Create A Helper In Magento

Postby jameswarner » Tue Aug 02, 2016 11:00 am

Hi,

Did you check out the following tutorial ?

http://www.pierrefay.com/magento-helper ... torial-113

This tutorial provide best guide on how to create and use of Helpers in magento.

It;s work fine for me, hope it will work best for your also.

Thanks
jameswarner
 
Posts: 8
Joined: Fri Jul 15, 2016 11:39 am

Re: How To Create A Helper In Magento

Postby JasonBlack » Wed Aug 17, 2016 8:42 am

In your module ./app/code/community/MyName/MyModule/etc/config.xml, within the <global> tags

<helpers>
<mymodule>
<class>MyName_MyModule_Helper</class>
</mymodule>
</helpers>

Then create the file ./app/code/community/MyName/MyModule/Helper/Data.php

<?php
class MyName_MyModule_Helper_Data extends Mage_Core_Helper_Abstract{
}

Then to call that module, you would use

$helper = Mage::helper('mymodule');
Intelligent document management system (dms) from the Intechcore company
JasonBlack
 
Posts: 1
Joined: Wed Aug 17, 2016 8:36 am


Return to Magento Developers

cron