Php 如何获取Magento客户ID
呃,我如何获得客户ID!!?这些都是我尝试过的东西!你能看出我做错了什么吗Php 如何获取Magento客户ID,php,magento,Php,Magento,呃,我如何获得客户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::getSingl
//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];
函数
isLoggedIn
只返回一个布尔值,表示客户是否已登录,而没有其他信息
客户会话必须具有以下功能:
getCustomerId
:它将返回客户idgetCustomer
:它将返回customer对象Mage::getSingleton('customer/session')->getId()
当我登录时,它甚至还没有通过登录布尔值。您是否尝试在Mage::app()之后添加以下行;Mage::getSingleton('core/session',array('name'=>'frontend');尽管您访问的是管理部分还是前端?它根本没有进入if语句!我已登录,但我添加了一个else语句echo“not loggin in”,这就是正在打印的内容。请尝试将存储id从admin更改为正确的客户存储id。这不会返回会话id吗?
Mage::getSingleton('customer/session')->getId()