Web サービスを呼び出して Cookie を追加する Magento 用のモジュールを開発しています。ユーザーが保存されたとき ( customer_save_after ) に呼び出されるクラスのメソッドが必要です。ローカルホストで開発しているときに何とか動作させることができましたが、実装しようとしたライブサイトでこのエラーが発生しました:
Mage レジストリ キー "_singleton/Eight18_Aqui4_Model_Observer" は既に存在します
ここに同様のスレッドがありますが、問題がどのように修正されたかについての実際の詳細は省略されています。
ここに私の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