我试过各种方法来获取customerID,但空值存储在变量中。请指教:)Magento检索客户ID
下面我试过的东西的残余物。该文件位于根目录中。
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';
}
也在这里查看我的答案http://stackoverflow.com/questions/14743362/how-to-convert-standalone- php-files-to-magentos-mvc/14780910#14780910当我在关于获取客户信息(这并不是很容易)上漫步时 – 2013-02-15 20:32:30
我实现了这些并获取对非成员函数的getId() ! – CaitlinHavener 2013-02-15 21:26:29
如果您看到我的'foreach($ dealer为$ id => $ obj)'id是一个数字,'$ obj'是客户对象。测试你的$ customers = Mage :: getModel('customer/customer') - > getCollection()'的结果以确保'$ customers'有一些东西。我使用'print_r($ customers)'。 – 2013-02-15 21:30:30