2015-11-12 57 views
0

遵循這個小教程創建一個觀察者來捕獲用戶註銷事件並將其重定向回主頁。它完美的作品:如何重定向Magento並顯示重定向到頁面上的自定義消息?

https://www.ashsmith.io/2012/12/making-use-of-observers-in-magento/

不過,我需要在用戶註銷後,顯示在主頁上的消息。

因此,這裏是我在觀察者做重定向和[儘量]顯示註銷消息代碼:

public function logoutRedirect($observer) 
    { 
     $observer->getControllerAction() 
      ->setRedirectWithCookieCheck('/); 
     // Mage::log('tried to redirect ~ did it work?'); 
     Mage::getSingleton('core/session')->addSuccess('You are now logged out.'); 
    } 

重定向工作,該消息沒有。我在這裏錯過了什麼?

回答

0

請使用:

Mage::getSingleton('customer/session')->addSuccess('You are now logged out.'); 

代替:

Mage::getSingleton('core/session')->addSuccess('You are now logged out.'); 

Magento會用客戶/會話爲顯示客戶的登錄和註銷的消息。

相關問題