阅读一些帖子后,我试图实现一个观察者在用户登录之前触发事件。我会解释:我有一个论坛和一个博客,使用另一个框架,我希望访问者只记录一次:博客,论坛或eshop。之后,他将被记录到其他地区。例如,我浏览论坛并登录论坛。然后,当我打开商店时,我已经登录。而相反的方法也是如此。Magento:在登录过程之前的火灾事件
它的作品,但只有一个问题:当我登录论坛/博客,如果我打开商店,我需要刷新页面,看看我登录。
实际上,它与标准Magento注销过程的行为相同:如果您点击Magento商店的“注销”链接,您仍然会看到您已经登录。有一个重定向/刷新主页和那么你会看到你注销的消息。 这里是我的代码:
应用程序/代码/社区/凡响/ UC的/ etc/config.xml文件:
[...]
<events>
<http_response_send_before>
<observers>
<UC>
<type>model</type>
<class>Fanxiang_UC_Helper_Data</class>
<method>ucSynlog</method>
</UC>
</observers>
</http_response_send_before>
</events>
[...]
和: 应用程序/代码/社区/凡响/ UC /助手/数据。 PHP
class Fanxiang_UC_Helper_Data extends Mage_Core_Helper_Abstract
{
public function ucSynlog($observer){
if(!empty($_COOKIE['Example_auth'])){
list($Example_uid, $Example_username) = explode("\t", uc_authcode($_COOKIE['Example_auth'], 'DECODE'));
list($Example_uid, $Example_username,$email) =uc_get_user($Example_username);
$customer = Mage::getModel('customer/customer')->setWebsiteId(Mage::app()->getStore()->getWebsiteId())->loadByEmail($email);
Mage::getSingleton('customer/session')->setCustomerAsLoggedIn($customer);
} else {
Mage::getSingleton('customer/session')->logout();
}
Mage::log(time(), null, "logfile.log");
}
}
PB:我想避免刷新页面看到我登录 任何想法或帮助是值得欢迎的!
熊龙
好!这样可行。我错过了这个事件... – 2010-11-04 01:17:16
不客气。 (请给这个答案一个勾号;-) – clockworkgeek 2010-11-04 01:44:46