2011-08-30 69 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獲取權限命令。祝你好運!