Street address #1 & #2
-
12-12-2019 - |
Question
I'm working on some Magento order export using SOAP and sales_order.info
Using the shipping_address
I'm able to get the obejct street. However this seem to include both Street 1 and Street 2. Which is the way of extracting both street 1st line and 2nd line, as I need to pass these values as two different fields to a separate system?
I use $shipdata['shipping_address']['street']
Solution
The street field contains street1 and street2 separated by a line break. In order to get one or the other just explode the string by \n
.
$street = explode('\n', $street);
You can then just pull $street[0]
for street1 or $street[1]
for street2. Alternatively if you are accessing the customer address object you can just call street1 or street2 directly to do the same thing:
$street1 = $address->getStreet1();
$street2 = $address->getStreet2();
OTHER TIPS
SPLITTING CUSTOMER ADDRESS FILED: street 0 and street 1
$customerAddress = Mage::getModel('customer/address')->load($customerAddressId);
$street = $customerAddress->getStreet();
$street0 = strtolower($street[0]);
$street1 = strtolower($street[1]);
//set "street0" as customer address...
if($street0 == $street1){
$customerAddress->setData('street',$street0);
}