magento 获取用户信息 How to get customer First Name, Last Name , Email Address ...

1. How to get customer First Name, Last Name , Email Address or Details in magento

Before geting the details of a customer you must to have check whether Customer is Logged in or not, If a customer is logged in then only you can get details fo the customer. To check whether user logged in or not click here or you can go to http://xhtmlandcsshelp.blogspot.com/2010/11/magento-check-if-user-logged-in-or-log.html to get the code. Then write the code below to get customer details


$customer = Mage::getSingleton('customer/session')->getCustomer();
$email = $customer->getEmail();// To get Email Id of a customer
$firstname = $customer->getFirstname();// To get Firstname of a customer
$lastnam e= $customer->getLastname();// To get Last name of a customer

 

 

来源: http://xhtmlandcsshelp.blogspot.com/2011/03/get-customer-details-in-magento-how.html

 

2. Magento: Get customer details : customer id, name, email

Get the logged in customer details like customer id, name, email, etc.

$customer = Mage::getModel('customer/customer')->load(1)->getData();
print_r($customer);
 

Output:

Array
(
    [entity_id] => 1
    [entity_type_id] => 1
    [attribute_set_id] => 0
    [website_id] => 1
    [email] => john.doe@example.com
    [group_id] => 1
    [increment_id] => 000000001
    [store_id] => 1
    [created_at] => 2007-08-30 23:23:13
    [updated_at] => 2008-08-08 12:28:24
    [is_active] => 1
    [firstname] => John
    [lastname] => Doe
    [password_hash] => 204948a4020ed1d0e4238db2277d5:eg
    [prefix] =>
    [middlename] =>
    [suffix] =>
    [taxvat] =>
    [default_billing] => 274
    [default_shipping] => 274
)
 

Getting customer firstname.

$customer = Mage::getModel('customer/customer')->load(1);
$customerFirstName = $customer->getFirstname();
 

Similarly, we can get lastname, email, etc. ( [website_id] = getWebsiteId() )

 

来源: http://ka.lpe.sh/2011/06/19/magento-get-customer-details-customer-id-name-email/

 

3. Magento: Get customer details via helper

 
echo $this->helper('customer')->getCustomerName();
// echo $customerName = Mage::helper('customer')->getCustomerName(); 

 

或者

echo "<pre>"; print_r($this->helper('customer')->getCustomer()->getData()); echo "</pre>";
//echo "<pre>"; print_r(Mage::helper('customer')->getCustomer()->getData()); echo "</pre>";

 

来源: http://stackoverflow.com/questions/416553/current-user-in-magento

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值