我怎么得到客户ID !!这些都是我尝试过的东西!你能看出我做错了吗?
//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];
答案 0 :(得分:64)
尝试
if(Mage::getSingleton('customer/session')->isLoggedIn()) {
$customerData = Mage::getSingleton('customer/session')->getCustomer();
echo $customerData->getId();
}
答案 1 :(得分:16)
最快的方法是
Mage::getSingleton('customer/session')->getId()
答案 2 :(得分:3)
函数isLoggedIn
仅返回一个布尔值,表示客户是否已登录而没有其他信息。
客户会话必须遵循以下功能:
getCustomerId
:将返回客户ID
getCustomer
:将返回客户对象。