繁体   English   中英

如何在magento中登录网站后显示客户姓名

[英]How to display customer name after login into site in magento

嗨,谁能告诉我在 magento 中登录网站后如何显示客户姓名。

截至目前,它显示为 DROPDOWN,而不是客户名称。 任何人都可以检查并解决这个问题,这对我很有帮助。因为我是 magento 的新手

app\\code\\core\\Mage\\Page\\Block\\Html\\header.php(来自这个文件的代码)。

 public function getWelcome()
{
    if (empty($this->_data['welcome'])) {
        if (Mage::isInstalled() && Mage::getSingleton('customer/session')->isLoggedIn()) {
            $this->_data['welcome'] = $this->__('Welcome, %s!', $this->escapeHtml(Mage::getSingleton('customer/session')->getCustomer()->getName()));
        } else {
            $this->_data['welcome'] = Mage::getStoreConfig('design/header/welcome');
        }
    }

    return $this->_data['welcome'];
}

这是作为“DROPDOWN”获取的代码,但没有获取如何获取名称并显示客户名称而不是下拉列表的代码。

<div data-toggle="dropdown" class="dropdown-toggle md-ink">
<span class="fa fa-cog hidden-sm hidden-lg hidden-md"></span>
<span class="hidden-xs"><?php echo $this->__('Dropdown') ?>
<span class="caret"></span></span>                                                          
</div>

检查是否有客户登录

if (Mage::getSingleton('customer/session')->isLoggedIn()) {

    //Load the customer's data

    $customer = Mage::getSingleton('customer/session')->getCustomer();

    $customer->getPrefix();
    $customer->getName(); // Full Name
    $customer->getFirstname(); // First Name
    $customer->getMiddlename(); // Middle Name
    $customer->getLastname(); // Last Name
    $customer->getSuffix();

    // All other customer data
    $customer->getWebsiteId(); // ID
    $customer->getEntityId(); // ID
    $customer->getEntityTypeId(); // ID
    $customer->getAttributeSetId(); // ID
    $customer->getEmail();
    $customer->getGroupId(); // ID
    $customer->getStoreId(); // ID
    $customer->getCreatedAt(); // yyyy-mm-ddThh:mm:ss+01:00
    $customer->getUpdatedAt(); // yyyy-mm-dd hh:mm:ss
    $customer->getIsActive(); // 1
    $customer->getDisableAutoGroupChange();
    $customer->getTaxvat();
    $customer->getPasswordHash();
    $customer->getCreatedIn(); // Admin
    $customer->getGender(); // ID
    $customer->getDefaultBilling(); // ID
    $customer->getDefaultShipping(); // ID
    $customer->getDob(); // yyyy-mm-dd hh:mm:ss
    $customer->getTaxClassId(); // ID
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM