Magento Tips & Tricks

Magento module Fatal error: helper class not found

It is pretty common magento error. Even if you yourself don’t use helper, Magento admin does. You should always create helper class in your custom module. File location depends on module code pool and could be located in
[magento_root]/app/code/local/[company]/[module]/helper/Data.php
or
[magento_root]/app/code/community/[company]/[module]/helper/Data.php

Sample file content:

Besides creating the Company_Module_Helper_Data class, you need to add class mapping to your config.xml

If you have created Data.php and has class mapping in config.xml, try following:

1. Clear cache ( System > Cache management )
2. If you are using compilation, disable it or run recompile ( System > Tools > Compilation )

What is going on under the hood ?

adminhtml.xml or system.xml could contain such line(s)

Magento passes the module argument to the Mage::helper() factory method.

Factory method looking for the class prefix to use in the node global/helpers/module/class. If helper part of config is missing, magento tries to load one from core codepool by prefixing the class id with mage_ and appending _helper.
As a result class prefix = mage_module_helper and it resolves to mage_module_helper_data. And autoloader tries to load Mage/Module/Helper/Data.php

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.