[英]How to get Magento customer ID
Ugh how do I get the customer ID!!? 我怎么得到客户ID !! These are all things I've tried!
这些都是我尝试过的东西! Can you see what I'm doing wrong?
你能看出我做错了什么吗?
//include_once "app/Mage.php";
require_once '/home/ab71714/public_html/app/Mage.php';
//Mage::app("default");
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
if($customer = Mage::getSingleton('customer/session')->isLoggedIn()) {
$customerData = Mage::getModel('customer/customer')->load($customer->getId())->getData();
print_r($customerData);
echo $customerData->getId();
}
//$customerData = Mage::getModel('customer/customer');
//$customerID = $customerData -> getId();
//$userinfo = $customerData->_origData; // fetch users info
$customerID=$customer -> getId();
//$customerID = $customerData->getEntityId();
//$customerID = $customerData[entity_id];
Try 尝试
if(Mage::getSingleton('customer/session')->isLoggedIn()) {
$customerData = Mage::getSingleton('customer/session')->getCustomer();
echo $customerData->getId();
}
最快的方法是
Mage::getSingleton('customer/session')->getId()
The function isLoggedIn
will only return a boolean as to if a customer is logged in and no other information. 函数
isLoggedIn
仅返回一个布尔值,表示客户是否已登录而没有其他信息。
The customer session does have to following functions: 客户会话必须具有以下功能:
getCustomerId
: which will return the customer id getCustomerId
:将返回客户ID
getCustomer
: which will return the customer object. getCustomer
:将返回客户对象。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.