17

I am learning to create a custom extension by following this tutorial, http://www.pierrefay.fr/category/developpement/magento

When I try to open extension admin I m getting Fatal error: Class 'Mage_Test_Helper_Data' not found in /var/www/html/dev/app/Mage.php on line 520

But I think I am not using helper class anywhere in the extension.Your suggestions are welcome.

Here is my config.xml file

<?xml version="1.0"?>
<config>
    <modules>
        <Package_Test>
            <version>1.0.0</version>
        </Package_Test>
    </modules>
    <frontend>
        <routers>
            <routerfrontend>
                <use>standard</use>
                <args>
                    <module>Package_Test</module>
                    <frontName>test</frontName>
                </args>
            </routerfrontend>
        </routers> 
        <layout>
            <updates>
                <test>
                    <file>test.xml</file>
                </test>
            </updates>
        </layout>    
    </frontend>
    <admin> 
        <routers>
            <test>  
                <use>admin</use>
                <args>
                    <module>Package_Test</module>
                    <frontName>admintest</frontName>
                </args>
            </test>
        </routers>
    </admin>
    <adminhtml>
        <layout>
            <updates>
                <test>
                    <file>test.xml</file>
                </test>
            </updates>
        </layout>
        <menu>
        <test translate="title" module="adminhtml">
            <title>My Module</title>
            <sort_order>100</sort_order>
            <children>
                <items module="Test">
                    <title>Address Book</title>
                    <action>admintest/adminhtml_index</action>
                </items>
            </children>
        </test>
        </menu>
    </adminhtml>
    <global>
         <helpers>
            <class>Package_Test_Helper</class>
         </helpers>
        <blocks>
            <test>
                <class>Package_Test_Block</class>
            </test>
        </blocks>
        <models>
            <test>
                <class>Package_Test_Model</class>
                <resourceModel>test_mysql4</resourceModel>
            </test>
            <test_mysql4>
                <class>Package_Test_Model_Mysql4</class>
                <entities>
                    <test>
                        <table>package_test</table>
                    </test>
                </entities>
            </test_mysql4>
        </models>
        <resources>
            <test_write>
                <connection>
                    <use>core_write</use>
                </connection>
            </test_write>
            <test_read>
                <connection>
                    <use>core_read</use>
                </connection>
            </test_read>
        </resources>
    </global>
</config>
scrowler
  • 24,273
  • 9
  • 60
  • 92
blakcaps
  • 2,647
  • 10
  • 46
  • 71

7 Answers7

25

If you have compilation enabled, trying disabling or re-compiling in System, Tools, Compilation.

If you can't get into the admin interface but have SSH access you can disable it there with:

php -f shell/compiler.php -- disable
php -f shell/compiler.php -- clear
php -f shell/compiler.php -- state

The final output should appear like:

Compiler Status:          Disabled
Compilation State:        Not Compiled
Collected Files Count:    0
Compiled Scopes Count:    0
reflexiv
  • 1,693
  • 1
  • 21
  • 24
16

Even if you yourself don't use helper, Magento admin does. That's why you should always include Data helper in your extensions. So the following code in your Helper/Data.php

class Package_Test_Helper_Data extends Mage_Core_Helper_Abstract
{

}

and

<global>
    <helpers>
        <test>
            <class>Package_Test_Helper</class>
        </test>
    </helpers>
</global>

in your config.xml should be enough.

Alexei Yerofeyev
  • 2,093
  • 1
  • 17
  • 21
4

To expand on the answer by @alexei-yerofeyev there are a few places that this can bite you.

Let's say that you define your helper like this:

<helpers>
    <package_test>
        <class>Package_Test_Helper</class>
    </package_test>
</helpers>

You may create an email template like this:

<template>
    <email>
        <test_email module="package_test">
            <label>Test Email</label>
            <file>package/test_email.html</file>
            <type>html</type>
        </test_submission>
    </email>
</template>

In this situation, <package_test> and module="package_test" need to match exactly including capitalization.

The same goes for code that uses your helper, like this:

Mage::helper('package_test')->something();

While this is typically in the [package]_[module] format, it's not always the case. You might come across a module Company_Widget with a helper called cmp_widg and you'll need to match that helper name.

Tyler V.
  • 2,471
  • 21
  • 44
  • Expanding again, there's a couple of examples of where this actually happens [in this answer](http://magento.stackexchange.com/a/116414/14992). – scrowler May 22 '16 at 20:27
  • Thanks, this was what was wrong for me. I had but only used module="test" and forgot to put the package name. – Jack Perry Dec 05 '17 at 22:59
2

If you add an extension and you face the same problem then just clear your cache folder manually because the admin will not allow to go inside. I was facing the same problem then I did this. The error has been removed. So that was the cache error.

Andro Selva
  • 53,910
  • 52
  • 193
  • 240
1

First of all you need to delete the "cache" Folder at var/cache ....

after delete go to your magento root folder and open index.php and replace code

Find this code

/**
  * Compilation includes configuration file
  */
  define('MAGENTO_ROOT', getcwd());
  $compilerConfig = MAGENTO_ROOT . '/includes/config.php';
  if (file_exists($compilerConfig)){
    include $compilerConfig;
  }

Replace with this code

 /**
   * Compilation includes configuration file<br />
   */
   define('MAGENTO_ROOT', getcwd());<br />
   /*
    $compilerConfig = MAGENTO_ROOT . '/includes/config.php';
    if (file_exists($compilerConfig)){
      include $compilerConfig;<br />
    }
   */

Finally refresh you Magento admin page..

Thank you for reading....I hope this answer is helpfull for you.

Markus W Mahlberg
  • 19,711
  • 6
  • 65
  • 89
Chintan Kotadiya
  • 1,335
  • 1
  • 11
  • 19
0

I ran into the same issue. It was really weird because it actually happened on a clone of production. Finally I could track down the issue to a permission problem. Changing all permissions recursively fixed it:

To change all the directories to 755 (-rwxr-xr-x): 
find /opt/lampp/htdocs -type d -exec chmod 755 {} \;

To change all the files to 644 (-rw-r--r--): 
find /opt/lampp/htdocs -type f -exec chmod 644 {} \;

Took permission commands from here. Good luck!

Community
  • 1
  • 1
Stefan
  • 8,456
  • 3
  • 29
  • 38
0

Check the helper calls in the Block / Adminhtml files... might be something in there calling the wrong helper.

James Dykes
  • 109
  • 5