2
我正在尝试以编程方式为客户创建一个新地址,这个客户是前一段时间为我导入的客户。创建一个客户地址到已经存在的客户 - Magento
我的代码:
//All variables about customer address info are filled
$customerModel = Mage::getModel('customer/customer');
$customer = $customerModel->setWebsiteId(1)->loadByEmail($_email);
if($customer->getId()) {
$addressData = array (
'firstname' => $customer->getFirstname(),
'lastname' => $customer->getLastname(),
'street' => "$_s1
$_s2
$_s3
$_s4",
'city' => $_city,
'country_id' => 'BR',
'region_id' => $_regionid,
'postcode' => $_cep,
'telephone' => $_tel,
'celular' => $_cel,
'is_default_billing' => 1,
'is_default_shipping' => 1
);
$address = Mage::getModel('customer/address');
$address->addData($addressData);
$customer->addAddress($address);
try {
print_r($addressData);
$customer->save();
}
catch (Exception $e) {
}
}
对象加载'$顾客的心不是我所需要的:一个完整的客户对象。 任何想法?
建议设置 '街头'=>阵列($ _ S1,$ _s2,...) – cottton