2011-08-30 76 views
15

我学习按照本教程中创建一个自定义扩展,http://www.pierrefay.fr/category/developpement/magentoMagento的助手类未找到错误

当我尝试打开扩展管理我m到处Fatal error: Class 'Mage_Test_Helper_Data' not found in /var/www/html/dev/app/Mage.php on line 520

但我觉得我不使用帮手在扩展的任何地方都可以上课。欢迎您提出建议。

这里是我的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> 
+1

你的配置文件坏了。/config/global/helpers部分有一个没有周围别名的类元素。它应该更像/ config/global/helpers/test/class –

+0

@blackcaps:你解决了这个问题,我面临同样的问题。 – Gowri

+0

@gowri:参考答案 – blakcaps

回答

15

即使你自己不使用的帮手,Magento管理一样。这就是为什么你总是应该在你的扩展中包含数据帮助器的原因。因此,在你的助手下面的代码/ Data.php

class Package_Test_Helper_Data extends Mage_Core_Helper_Abstract 
{ 

} 

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

在你的config.xml应该够了。

+0

我添加它。但是这din't修复 – blakcaps

+0

是的,我的错误。我编辑了我的答案并插入了正确的类名。 –

+0

它不工作。我认为别的什么造成了问题 – blakcaps

25

如果您已启用编译,请尝试在System,Tools,Compilation中禁用或重新编译。

如果你不能进入管理界面,但有SSH访问,你可以有禁用它:

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

最终的输出应该看起来像:

Compiler Status:   Disabled 
Compilation State:  Not Compiled 
Collected Files Count: 0 
Compiled Scopes Count: 0 
+0

谢谢,那是为我做的! – bouke

+0

OH MY谢谢你! –

+0

@reflexiv感谢这个 –

0

检查辅助电话在Block/Adminhtml文件中......可能会在那里调用错误的帮助程序。

2

如果你添加一个扩展名,并且你面临同样的问题,那么只需手动清除缓存文件夹因为管理员不允许进去。我面临同样的问题,然后我做到了这一点。该错误已被删除。所以这是缓存错误。

1

首先你需要删除的VAR /缓存的“缓存”文件夹中....

后删除去你的Magento的根文件夹并打开index.php文件并替换代码

查找这个代码

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

替换与此代码

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

最后刷新你Magento管理页面..

谢谢你的阅读....我希望这个答案对你有帮助。

4

为了扩大@ alexei-yerofeyev的答案,有几个地方,这可以咬你。

比方说,你这样定义你的助手:

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

您可以创建一个电子邮件模板是这样的:

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

在这种情况下,<package_test>module="package_test"需要匹配准确包括大写字母在内的

这同样适用于使用你的助手,这样的代码:

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

虽然这通常是在[package]_[module]格式,它并不总是如此。您可能会遇到一个名为cmp_widg的帮助程序Company_Widget,您需要匹配该帮助程序名称。

+0

再次展开,有几个实际发生的例子[在这个答案](http://magento.stackexchange.com/a/116414/14992)。 –

+0

谢谢,这对我来说是错的。我有,但只使用了module =“test”,忘记放上包名。 –

0

我遇到了同样的问题。这真的很奇怪,因为它实际上发生在生产的克隆上。最后,我可以找出许可问题。更改所有权限递归修复:

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 {} \; 

here获取权限命令。祝你好运!

相关问题