16

I have installed one module extension which throws an fatal error

"Fatal error: Class 'Mage_Giftcards_Helper_Data' not found in ..../app/Mage.php on line 546" in admin.

I have reffered this link https://stackoverflow.com/a/9191286/2919940 and this link as well https://magento.stackexchange.com/a/7133/3693

But I have

<global>
<helpers>
        <giftcards>
            <class>Webtex_Giftcards_Helper</class>
        </giftcards>
    </helpers>
</global>

in my config.xml and I have this class

class Webtex_Giftcards_Helper_Data extends Mage_Core_Helper_Data{
// my methods
}

declared at /app/code/local/Webtex/Giftcards/Helper/Data.php path.

I have disabled compiler and cleared cache by making empty var/cache directory.

I found everwhere that config.xml should have helper class define and Data.php should have declare that helper class.

But I have both of them in my case, what can be reason for this error ? I have tested that module on my fresh magento installation as well,

Magento version is 1.7.0.2

Please provide help for this error ?? If there's conflicts of class names how can we debug that ??

Thanks

1
  • Let me know if there is any additional information you need from my answer or if you have an update.
    – philwinkle
    Commented Oct 26, 2013 at 15:39

3 Answers 3

20

This is common when referencing a missing helper. In many cases the class name itself is malformed or your shortname referencing it is incorrect, which is why Magento is looking for it in the path Mage_Giftcards_Helper_Data (see example 1 below). For the following examples I have set up a module called MyCompany_MyModule.

These are just a few of the many ways you can go awry with defining helpers:


Incorrect helper class alias:

I reference my helper as:

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

I get the error:

Fatal error: Class 'Mage_Mycompany_Helper_Data' not found

What went wrong?

My helper class alias is defined as mymodule:

<helpers>
    <mymodule>
        <class>MyCompany_MyModule_Helper</class>
    </mymodule>
</helpers>

Changing my shortcode to Mage::helper('mymodule') produced the desired result.


Malformed class name

I reference my helper (correctly this time):

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

I receive:

Fatal error: Class 'MyCompany_MyModule_Helper_Data' not found

What went wrong?

My class definition was missing "_Data":

class MyCompany_MyModule_Helper extends Mage_Core_Helper_Abstract
{


}

Helper/Custom:

This is similar to what happens when you try to refer to a helper class within a file not named "Data.php".

I reference my helper as:

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

My module helper path was defined as:

<helpers>
    <mymodule>
        <class>MyCompany_MyModule_Helper</class>
    </mymodule>
</helpers>

I have a class file in app/code/local/MyCompany/MyModule/Helper/Custom.php

I get the error:

Fatal error: Class 'Mage_Custom_Helper_Data' not found

What went wrong?

You need to specify other helper classes in a particular module as sub-paths to your module helper's shortname. This is similar to how blocks and models work - but at the topmost level there is no subfolder.

I fix this error by referencing my Custom.php helper class file as such:

$helper = Mage::helper('mymodule/custom');
1
4

This only happen when you install extension with enable compiler Here is what you have to do

1 Step app/etc/module/your module which you installed recently disable module

2 Step Login to admin /system/tools compiler disable compiler Upload code again it will work fine then you can compile your code again

good luck

1
  1. Make sure that the Data.php file present under your

codepool/extension_name/module_name/Helper/Data.php

  1. If the Data.php present in the above mentioned directory open that file and copy the class name, Basically the class name having the Magento naming sense like

packagename_modulename_foldername(Helper or Block) _ filename(Data.php)

<?php

class package_module_Helper_Data{

}
  1. Move to magento root folder and make sure if the package_module_Helper_Data.php present in

includes/src/

  1. If you are not see, create a php file with that name (which you got in error) under the src directory
  2. Copy contents of Data.php and paste it in newly created file that's all. I'm sure it will help you
  3. Still if you get error or magento showing nothing about the extension, just disable the compile mode under magento System->Tools->Compilation

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.