2

我正在尝试将客户从旧站点导入我的新 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'] 此字段包含街道地址我还有城市、州、邮政编码、邮政编码

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

4

1 回答 1

10

好吧,我在 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());
}
于 2013-01-01T10:31:48.263 回答