Adding address programmatically in magento

$addressData =  array (
                    [prefix] => test
                    [firstname] => test
                    [middlename] => test
                    [lastname] => test
                    [suffix] => tes
                    [company] => test
                    [street] => 34
24
                    [city] => 234
                    [country_id] => US
                    [region] => Alabama
                    [region_id] => 1
                    [postcode] => 234
                    [telephone] => 234
                    [fax] => 234
                    [is_default_billing] => 1
                    [is_default_shipping] => 
                );
 
 $customer = Mage::getModel('customer/customer');
 $customer->loadByEmail('test@test.com');
 $address   = Mage::getModel('customer/address');
 $address->addData($addressData);
 $customer->addAddress($address);

 $customer->save();

 

Advertisements

2 thoughts on “Adding address programmatically in magento

  1. Excellent post. I was checking constantly this blog
    and I am impressed! Extremely useful info specially the last part 🙂 I care for such info much.
    I was looking for this certain info for a very long time.

    Thank you and good luck.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s