1

I've exported my customers to a CSV file. The problem is, that the _address_street has the first line of the address as well as the suburb, merged into one?

Is that normal? Is there a field for address line 2?

I'm using Magento 1.9

I tried to actually reimport that data back into Magento...and it forced everything into Address Line 1.

1 Answer 1

1

Seems, this is expected behavior by design. Please, look at customer address backend model:

class Mage_Customer_Model_Resource_Address_Attribute_Backend_Street
    extends Mage_Eav_Model_Entity_Attribute_Backend_Abstract
{
    /**
     * Prepare object for save
     *
     * @param Varien_Object $object
     * @return Mage_Customer_Model_Resource_Address_Attribute_Backend_Street
     */
    public function beforeSave($object)
    {
        $street = $object->getStreet(-1);
        if ($street) {
            $object->implodeStreetAddress();
        }
        return $this;
    }
}

And Mage_Customer_Model_Address_Abstract

/**
 * set address street informa
 *
 * @param unknown_type $street
 * @return unknown
 */
public function setStreet($street)
{
    if (is_array($street)) {
        $street = trim(implode("\n", $street));
    }
    $this->setData('street', $street);
    return $this;
}


/**
 * To be used when processing _POST
 */
public function implodeStreetAddress()
{
    $this->setStreet($this->getData('street'));
    return $this;
}

Since Module ImportExport uses attribute's backend models, so this is expected behavior.

6
  • Any idea how I can import data so it separates line1 and 2? Should I seperate them with a \n ?
    – pozitronic
    Commented Sep 4, 2014 at 13:49
  • Yes, you absolutely right, i.e. you should it like in Mage_Customer_Model_Address_Abstract::setStreet().
    – user13804
    Commented Sep 4, 2014 at 13:52
  • Also, please, look at following method Mage_Customer_Model_Address_Abstract::explodeStreetAddress(): /** * Create fields street1, street2, etc. * * To be used in controllers for views data * */ public function explodeStreetAddress() { $streetLines = $this->getStreet(); foreach ($streetLines as $i=>$line) { $this->setData('street'.($i+1), $line); } return $this; } I.e. every address street will separated as street[line number]
    – user13804
    Commented Sep 4, 2014 at 13:57
  • I'm a real beginner. I'm just cleaning some data in Excel, and trying to import it in Magento. I tried adding a \n in excel, but it didn't work. I also tried it with quotations marks - "\n" that also didn't work. Is what your suggesting to create a column in excel called "_address_street2" ?
    – pozitronic
    Commented Sep 4, 2014 at 14:03
  • You can add new line in cell with help of keys combination Alt+Enter (in Windows). I've checked it once again, yes second line will merged through "\n", so add new line in Excel (as I described) and try again.
    – user13804
    Commented Sep 4, 2014 at 14:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.