0

How can I import a customer's address line 2 using the AvS importer for Magento? The example shows only one line and the names do not match the Magento fields, so I'm not sure how to handle this.

$data = array(
array(
    'email' => 'customer@company.com',
    '_website' => 'base',
    'group_id' => 1,
    'firstname' => 'John',
    'lastname' => 'Doe',
    '_address_firstname' => 'John',
    '_address_lastname' => 'Doe',
    '_address_street' => 'Main Street 1',
    '_address_postcode' => '12345',
    '_address_city' => 'Springfield',
    '_address_country_id' => 'US',
    '_address_telephone' => '+1 2345 6789',
    '_address_default_billing_' => 1,
    '_address_default_shipping_' => 0,
));

I tried adding '_address_street2', but that does not work.

Corgalore
  • 2,486
  • 2
  • 23
  • 32

1 Answers1

2

You can use the \n (newline) in the _address_street field as divider between the first and second line.

...
'_address_street' => "Main Street\n1",
...

Use double quotes for this entry in the array to have the \n be parsed as newline

The result will be stored as provided in the database table customer_address_entity_text, which is in Magento terms a multiline field. For displaying it in the Magento front and backend Magento will automatically split it up by the newline and place this in separate input fields.

Gerard
  • 21
  • 1
  • I suppose that would work, but I would really like it to go into the Address 2 field that Magento provides. – Corgalore Aug 13 '14 at 13:42
  • Gerard is correct; a new line is the correct way to do this in Magento. The second address line that you see in the Magento Admin and other forms is a bit misleading. Both the first and second lines of the address are concatenated with a newline into one attribute value, and stored in the customer_address_entity_text table. – Tyler V. Jan 05 '15 at 23:56