How can I call helper of another module in my module?
When I try
Mage::helper(‘helperclass’)->getValueClass(”,$id)
It gives me error:
Fatal error: Class ‘Mage_Helperclass_Helper_Data’ not found in C:\wamp\www\example\app\Mage.php on line 516
The helper class name is Test_Helperclass_Helper_Data.
This is the correct way to call a helper, but your error suggests that you’ve not set up your module properly. I presume your module exists in
app/code/local/Test/Helperclass, and that you have enabled your module with aapp/etc/modules/Test_Helperclass.xmlfile.When you call Magento’s factories, such as
Mage::getModel(),Mage::getSingleton(), orMage::helper(), you don’t provide the full class name, but a reference to the class you’d like to instantiate.This has the format
modulename/classname.In our case, the module name is
helperclass(doesn’t have to bare any relationship to the actual name of the module, it could just as well befoobar), and our class name isdata. So we’re essentially callingMage::helper('helperclass/data'), but Magento lets us shorten that down toMage::helper('helperclass').We need to tell Magento the rule behind expanding
helperclass/data -> Test_Helperclass_Helper_Data. We do this in the module configuration file atapp/code/local/Test/Helperclass/etc/config.xml: