Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Set customers address as delivery-address and/or invoice-address via php
 
Aikanet
Member
 
Avatar
Total Posts:  40
Joined:  2009-03-16
Düsseldorf, Germany
 

Hi there!
I’m trying to import some customers into magento 1.6 CE via php-script.
My problem is to import the addresses (delivery and invoice) - i do not understand the logic of magento how to set a address as default delivery-address or as default invoice-address. In the models i also do not find a setting for this. Is the position crucial for this? Anyone who has a solution for this?

Here is my code:

...

    
$customer Mage::getModel("customer/customer");
    
    
$customer->setData(unserialize($row->userdata));
    
    if(
$row->deliveryaddress != ''{
        $deliveryAddress 
Mage::getModel('customer/address');
        
$deliveryAddress->setData(unserialize($row->deliveryaddress));
        
$customer->addAddress($deliveryAddress);
    
}
    
if($row->invoiceaddress != ''{
        $invoiceAddress 
Mage::getModel('customer/address');
        
$invoiceAddress->setData(unserialize($row->invoiceaddress));
        
$customer->addAddress($invoiceAddress);
    
}
    
if($row->alternativeaddress1 != ''{
        $customer
->addAddress(unserialize($row->alternativeaddress1));
    
}
    
if($row->alternativeaddress2 != ''{
        $customer
->addAddress(unserialize($row->alternativeaddress2));
    
}
    $customer
->save();

    ...

Regards,
Rafael Kutscha

EDIT: Checked my import. Really seems to be the position. Can anyone confirm this?

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top