gpt4 book ai didi

php - Magento : Add customer default billing address

转载 作者:行者123 更新时间:2023-12-04 23:24:25 24 4
gpt4 key购买 nike

我正在尝试将客户从旧站点导入到我的新 magento 安装中,并希望将客户地址设置为我试过的 magento 客户默认账单地址

$customer = $this->getCustomerModel();
$address = Mage::getModel('customer/address');
$customer->addAddress($results[0]['address']); //this says trying to save invalide object
$address ->addAddress($results[0]['address']); //this says undefined method

$results[0]['address'] 该字段包含街道地址,我还有城市、州、 zip 、邮政编码

关于如何将我的客户地址设置为默认帐单或送货地址的任何想法..

最佳答案

嗯,我是在 Anoop 先生的帮助下找到的。

$_custom_address = array (
'firstname' => 'Branko',
'lastname' => 'Ajzele',
'street' => array (
'0' => 'Sample address part1',
'1' => 'Sample address part2',
),
'city' => 'Osijek',
'region_id' => '',
'region' => '',
'postcode' => '31000',
'country_id' => 'HR', /* Croatia */
'telephone' => '0038531555444',
);
$customAddress = Mage::getModel('customer/address');
//$customAddress = new Mage_Customer_Model_Address();
$customAddress->setData($_custom_address)
->setCustomerId($customer->getId())
->setIsDefaultBilling('1')
->setIsDefaultShipping('1')
->setSaveInAddressBook('1');
try {
$customAddress->save();
}
catch (Exception $ex) {
//Zend_Debug::dump($ex->getMessage());
}

关于php - Magento : Add customer default billing address,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14108956/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com