xml 未找到 Magento 助手类错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7242292/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Magento Helper Class Not Found Error
提问by blakcaps
I am learning to create a custom extension by following this tutorial, http://www.pierrefay.fr/category/developpement/magento
我正在学习按照本教程创建自定义扩展,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
当我尝试打开扩展管理员时,我得到 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
这是我的 config.xml 文件
<?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>
采纳答案by Alexei Yerofeyev
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
即使您自己不使用助手,Magento 管理员也会使用。这就是为什么您应该始终在扩展中包含数据助手的原因。所以你的 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.
在您的 config.xml 中应该就足够了。
回答by reflexiv
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:
如果您无法进入管理界面但具有 SSH 访问权限,您可以在那里禁用它:
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
回答by Tyler V.
To expand on the answer by @alexei-yerofeyev there are a few places that this can bite you.
要扩展@alexei-yerofeyev 的答案,有几个地方可能会让您感到厌烦。
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 exactlyincluding capitalization.
在这种情况下,<package_test>并module="package_test"需要搭配恰好包括大小写。
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_Widgetwith a helper called cmp_widgand you'll need to match that helper name.
虽然这通常是[package]_[module]格式,但并非总是如此。您可能会遇到一个Company_Widget名为 helper的模块,cmp_widg您需要匹配该 helper 名称。
回答by user1755471
If you add an extension and you face the same problem then just clear your cache folder manuallybecause 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.
如果您添加了一个扩展并且遇到了同样的问题,那么只需手动清除您的缓存文件夹,因为管理员不允许进入。我遇到了同样的问题,然后我做了这个。该错误已被删除。所以这就是缓存错误。
回答by chintan kotadiya
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
首先,您需要删除 var/cache 中的“缓存”文件夹 ....
删除后转到您的 magento 根文件夹并打开 index.php 并替换代码
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..
最后刷新你的 Magento 管理页面..
Thank you for reading....I hope this answer is helpfull for you.
感谢您阅读......我希望这个答案对您有所帮助。
回答by Stefan Diabo
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!
从这里获取权限命令。祝你好运!
回答by James Dykes
Check the helper calls in the Block / Adminhtml files... might be something in there calling the wrong helper.
检查 Block / Adminhtml 文件中的帮助程序调用...可能是那里调用了错误的帮助程序。

