本文介紹了Magento 的當前用戶?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我正在自定義產品查看頁面,我需要顯示用戶名.如何訪問當前用戶的帳戶信息(如果他已登錄)以獲取姓名等?
I'm customizing the product view page and I need to show the user's name. How do I access the account information of the current user (if he's logged in) to get Name etc. ?
推薦答案
在app/code/core/Mage/Page/Block/Html/Header.php"下找到:
Found under "app/code/core/Mage/Page/Block/Html/Header.php":
public function getWelcome()
{
if (empty($this->_data['welcome'])) {
if (Mage::app()->isInstalled() && Mage::getSingleton('customer/session')->isLoggedIn()) {
$this->_data['welcome'] = $this->__('Welcome, %s!', Mage::getSingleton('customer/session')->getCustomer()->getName());
} else {
$this->_data['welcome'] = Mage::getStoreConfig('design/header/welcome');
}
}
return $this->_data['welcome'];
}
所以它看起來像 Mage::getSingleton('customer/session')->getCustomer()
將獲取您當前登錄的客戶 ;)
So it looks like Mage::getSingleton('customer/session')->getCustomer()
will get your current logged in customer ;)
獲取當前登錄的管理員:
To get the currently logged in admin:
Mage::getSingleton('admin/session')->getUser();
這篇關于Magento 的當前用戶?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!