Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/251.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何获取Magento客户ID_Php_Magento - Fatal编程技术网

Php 如何获取Magento客户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

呃,我如何获得客户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];

函数
isLoggedIn
只返回一个布尔值,表示客户是否已登录,而没有其他信息

客户会话必须具有以下功能:

  • getCustomerId
    :它将返回客户id

  • getCustomer
    :它将返回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()