Magento:我如何回应用户名

Lol*_*ita 4 echo magento username

我使用现代主题

我在标题上有一个实时聊天按钮,我想在我的模板中解析信息

这是实时聊天按钮:

<!-- http://www.LiveZilla.net Chat Button Link Code --><a href="[removed]void(window.open('http://xxxxxx.fr/livezilla.php?code=BOUTIQUE&amp;en=<!!CUSTOMER NAME!!>&amp;ee=<!!!CUSTOMER EMAIL!!>.........
Run Code Online (Sandbox Code Playgroud)

我需要替换用户的姓名和电子邮件(如果已记录)

该按钮位于我主页的标题中

我如何回应这两个信息?

我试过了

<?php echo $this->htmlEscape($this->getCustomer()->getName()) ?>
Run Code Online (Sandbox Code Playgroud)

但没有奏效:

致命错误:在第36行的/home/xxx/public_html/app/design/frontend/default/modern/template/page/html/header.phtml中的非对象上调用成员函数getFirstname()

liq*_*ity 9

这是正常的.与模板对应的块app/design/frontend/default/modern/template/page/html/header.phtml位于app/code/Core/Page/Block/Html/Header.php.

如果你读取块的代码,你会发现没有名为'getCustomer()'的函数.当您尝试调用$this->getCustomer()->getName();模板页面时,由于函数getCustomer()不存在,它不会返回任何内容.

结果是你试图在什么都没有调用'getName()'然后出现错误信息:Fatal error: Call to a member function getFirstname() on a non-object.

您可以阅读:在非对象上调用成员函数getFirstname().

如果您想在header.phtml中获取客户名称,您应该:

$session = Mage::getSingleton('customer/session');
if($session->isLoggedIn()) {
   $customer = $session->getCustomer();
   echo $customer->getName();
   echo $customer->getFirstname();
}
Run Code Online (Sandbox Code Playgroud)

雨果.