有没有方法通过ID加载客户的地址?通过ID加载客户地址,Magento
像这样的客户装载由用户名呢:
$customer->loadByEmail($customerEmail);
我需要它,因为我想知道,如果该地址已经存在,所以我决定创建一个新的或更新现有的一个
有没有方法通过ID加载客户的地址?通过ID加载客户地址,Magento
像这样的客户装载由用户名呢:
$customer->loadByEmail($customerEmail);
我需要它,因为我想知道,如果该地址已经存在,所以我决定创建一个新的或更新现有的一个
假设“ID”指的地址ID(而不是用户ID),然后
$id = 5;
Mage::getModel('customer/address')->load($id);
(它总是明智的ID载入时做安全检查)
见deleteAction ()在应用程序/代码/核心/法师/客户/控制器/ AddressController.php
谢谢,工作完美 – jonathanwiesel
我用这个,因为他们可以设置法师多个地址...
$customer = Mage::getModel('customer/customer')
->load($customer_id); // insert customer ID
foreach ($customer->getAddresses() as $address)
{
$data = $address->toArray();
var_dump($data);
}
当然var_dump
将显示所有阵列数据的..这回事给你操纵和拉出你在这一点上寻找的地址。
尝试以下方法:
#customer id here
$customerId = 1;
#load customer object
$customer = Mage::getModel('customer/customer')->load($customerId); //insert cust ID
#create customer address array
$customerAddress = array();
#loop to create the array
foreach ($customer->getAddresses() as $address)
{
$customerAddress[] = $address->toArray();
}
#displaying the array
echo '<pre/>';print_r($customerAddress);exit;
哪个地址和在什么情况下? –