简体   繁体   English

Magento检索客户ID

[英]Magento retrieve customer ID

I've tried various methods to get the customerID but an empty value is stored in the variable. 我尝试了各种方法来获取customerID,但是将空值存储在变量中。 Please advise :) 请指教 :)

Below remnants of things I've tried. 下面是我尝试过的东西的残余。 The file is located in the root. 该文件位于根目录中。

require_once '/home/ab71714/public_html/app/Mage.php';
//Mage::app("default");

Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);

/* if(Mage::getSingleton('customer/session')->isLoggedIn()) {
     $customerData = Mage::getSingleton('customer/session')->getCustomer();
      echo $customerData->getId();
 } */

 if(Mage::getSingleton('customer/session')->isLoggedIn()) {
    $customerId = Mage::getModel('customer/session')->getCustomer()->getId();
} else {
    echo 'Not logged In';
}
require "/home/ab71714/public_html/app/Mage.php";
umask(0);
Mage::app();

$session = Mage::getSingleton('customer/session');
if($session->isLoggedIn()) {
    print_r($session);
    $customerId = $session->getCustomer()->getId();
} else {
    echo 'Not logged In';
}

For more information: 欲获得更多信息:

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

if(Mage::getSingleton('customer/session')->isLoggedIn()) {
    $customerData = Mage::getSingleton('customer/session')->getCustomer();
    echo $customerData->getId();
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM