我正在为Magento开发一个模块,它调用一个web服务并添加一个cookie。我希望在保存用户( customer_save_after )时调用类中的一个方法。在本地主机上开发时,我不知何故能够让它正常工作,但在我尝试实现它的活动站点上,我得到了这个错误:
Mage注册表项“_singleton/Eight18 18_Aqui4_Model_观察者”已经存在
有一个类似的线程这里,但它忽略了如何解决问题的实际细节。
下面是我的config.xml:( customer_save_after事件似乎是错误开始的地方)
<?xml version="1.0"?>
<config>
<global>
<helpers>
<aqui4>
<class>Eight18_Aqui4_Helper</class>
</aqui4>
</helpers>
<modules>
<Eight18_aqui4>
<version>0.1.0</version>
</Eight18_aqui4>
</modules>
</global>
<adminhtml>
<acl>
<resources>
<all>
<title>Allow Everything</title>
</all>
<admin>
<children>
<Eight18_Aqui4>
<title>Aqui4 Module</title>
<sort_order>10</sort_order>
</Eight18_Aqui4>
</children>
</admin>
</resources>
</acl>
<layout>
<updates>
<aqui4>
<file>aqui4.xml</file>
</aqui4>
</updates>
</layout>
</adminhtml>
<default>
<main>
<enable>1</enable>
<siteid>0</siteid>
<sitetoken>0</sitetoken>
</main>
</default>
<frontend>
<events>
<customer_save_after>
<observers>
<aqui4_observer>
<class>Eight18_Aqui4_Model_Observer</class>
<method>start_aqui4</method>
</aqui4_observer>
</observers>
</customer_save_after>
</events>
<routers>
<aqui4>
<use>standard</use>
<args>
<module>Eight18_Aqui4</module>
<frontName>aqui4</frontName>
</args>
</aqui4>
</routers>
<layout>
<updates>
<aqui4>
<file>aqui4.xml</file>
</aqui4>
</updates>
</layout>
</frontend>
</config>/Company/Module/Model/observer.php:
Public function start_aqui4() {//THIS IS CALLED BY THE EVENT OBSERVER ON CUSTOMER CREATION
// get variables
$userEmail = Mage::helper('aqui4')->getUserEmail();
$userFirstName = Mage::helper('aqui4')->getUserFirstName();
$userLastName = Mage::helper('aqui4')->getUserLastName();
$siteID = Mage::helper('aqui4')->getSiteID();
$siteToken = Mage::helper('aqui4')->getSiteToken();
$expire=time()+60*60*24*30.42*6;//THE LAST NUMBER IS THE MONTHS
$randomNumber = rand(0, pow(10, 5));//SERVICE EXPECTS RAND NUMBER
if(isset( $_COOKIE['aqui4userid'] )){//CHECK TO SEE IF USER ALREADY HAS A COOKIE
return;
}
else{//CHANGE JSON DATA SO JSON_DECODE CAN READ IT
$getContent = file_get_contents("http://www.domain.com/service.ashx?siteId=" . $siteID . "&token=" . $siteToken . "&email=" . $userEmail . "&data={\"firstName\":\"" . $userFirstName . "\",\"lastName\":\"" . $userLastName . "\",\"email\":\"" . $userEmail . "\",\"company\":\"\",\"position\":\"\",\"country\":\"\"}", true);
$getContent = str_replace('function __authenticate() ', '', $getContent);
$getContent = str_replace('{ return ', '', $getContent);
$getContent = str_replace(';}', '', $getContent);
$getContent = str_replace('\'', '"', $getContent);
$getContent = str_replace(': "', ':"', $getContent);
//SET THE USER ID AND ERROR VARS BASED ON DATA PASSED BACK
$getContentArray = json_decode($getContent, true);
$error = $getContentArray['HasError'];
$userID = $getContentArray['UserId'];
if($error){
if($error != "True"){//SERVICE RETURNS NO ERROR
setcookie("aqui4userid", $userID, $expire);
return;
}
else{//NO COOKIE SET - USER WAS NOT ADDED
return;
}
}
}
}}
最后是system.log文件:
2012-07-24T23:21:52+00:00 ERR (3): Warning: include(/var/www/clients/client3/web4/web/includes/src/Eight18_Aqui4_Model_Observer.php): failed to open stream: No such file or directory in /var/www/clients/client3/web4/web/includes/src/Varien_Autoload.php on line 93
2012-07-24T23:21:52+00:00 ERR (3): Warning: include(): Failed opening '/var/www/clients/client3/web4/web/includes/src/Eight18_Aqui4_Model_Observer.php' for inclusion (include_path='/var/www/clients/client3/web4/web/includes/src:.:/usr/share/php:/usr/share/pear') in /var/www/clients/client3/web4/web/includes/src/Varien_Autoload.php on line 93
2012-07-24T23:21:52+00:00 ERR (3): Warning: include(/var/www/clients/client3/web4/web/includes/src/Eight18_Aqui4_Model_Observer.php): failed to open stream: No such file or directory in /var/www/clients/client3/web4/web/includes/src/Varien_Autoload.php on line 93
2012-07-24T23:21:52+00:00 ERR (3): Warning: include(): Failed opening '/var/www/clients/client3/web4/web/includes/src/Eight18_Aqui4_Model_Observer.php' for inclusion (include_path='/var/www/clients/client3/web4/web/includes/src:.:/usr/share/php:/usr/share/pear') in /var/www/clients/client3/web4/web/includes/src/Varien_Autoload.php on line 93
2012-07-24T23:21:54+00:00 ERR (3): Warning: include(/var/www/clients/client3/web4/web/includes/src/Eight18_Aqui4_Model_Observer.php): failed to open stream: No such file or directory in /var/www/clients/client3/web4/web/includes/src/Varien_Autoload.php on line 93
2012-07-24T23:21:54+00:00 ERR (3): Warning: include(): Failed opening '/var/www/clients/client3/web4/web/includes/src/Eight18_Aqui4_Model_Observer.php' for inclusion (include_path='/var/www/clients/client3/web4/web/includes/src:.:/usr/share/php:/usr/share/pear') in /var/www/clients/client3/web4/web/includes/src/Varien_Autoload.php on line 93发布于 2012-07-25 00:02:03
短版本:您的生产系统运行在“编译器模式”,您还没有编译您的模块类。
您的生产服务器正在运行Magento的"编译模式“(自链接)打开。从错误消息Magento的日志记录可以看出
ERR (3): Warning: include(): Failed opening '/var/www/clients/client3/web4/web/includes/src/Eight18_Aqui4_Model_Observer.php'
for inclusion (include_path='/var/www/clients/client3/web4/web/includes/src:.:/usr/share/php:/usr/share/pear') in /var/www/clients/client3/web4/web/includes/src/Varien_Autoload.php on line 93Magento正在includes/src寻找一个类。这就是放置编译类的地方。此外,PHP正试图包含一个完全强调的文件名Eight18_Aqui4_Model_Observer.php。这只有在编译器模式打开时才会发生。
当您将模块更改推送到生产中时,您需要重新编译模块。你可以从
System -> Tools -> Compilation或使用命令行编译器脚本。
$ php shell/compiler.php
Usage: php -f compiler.php -- [options]
state Show Compilation State
compile Run Compilation Process
clear Disable Compiler include path and Remove compiled files
enable Enable Compiler include path
disable Disable Compiler include path
help This helphttps://stackoverflow.com/questions/11640822
复制相似问题