Magento Helper Class Not Found Error
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>
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
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.
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.
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.
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.
Check the helper calls in the Block / Adminhtml files... might be something in there calling the wrong helper.
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!
精彩评论