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

spliting two street addresses
 
pankajk
Member
 
Avatar
Total Posts:  38
Joined:  2008-04-15
Mumbai -101, Maharastra, India
 

I’m using following code to get a information for customer

$session Mage::getSingleton('customer/session
$address = $session->getCustomer()->getAddresses();        
$customer = $session->getCustomer();
$customerData['
street'] = $address[$i]->street;

but my problem is I am getting street 1 and street2 added I want that to be separated so what object and what function need to call
to get these street separated.

pls help as I got stuck by this prob. as I can’t even explode these street addresses.

 
Magento Community Magento Community
Magento Community
Magento Community
 
MageParts
Guru
 
Avatar
Total Posts:  415
Joined:  2007-11-18
 

I’m not sure, but you could try this:

$i 0;
foreach (
$address as $a{
    $customerData[
'street'.$i] $a->getStreet();
    
$i++;
}
 
Magento Community Magento Community
Magento Community
Magento Community
 
pankajk
Member
 
Avatar
Total Posts:  38
Joined:  2008-04-15
Mumbai -101, Maharastra, India
 

thanks for your reply but it is not working
as I wanted to find a object of address so that I can find two streets

 
Magento Community Magento Community
Magento Community
Magento Community
 
MageParts
Guru
 
Avatar
Total Posts:  415
Joined:  2007-11-18
 

Well, I’m not sure what you are seeking mate. But here is something which might help you:

$session Mage::getSingleton('customer/session');
$addresses $session->getCustomer()->getAddresses();
foreach (
$session->getCustomer()->getAddresses() as $address{
    
echo $address->getData('postcode');
}

And I’ve checked that code, it works wink. At least in verison 1.1.8. You could also use this:

$session Mage::getSingleton('customer/session');
$addresses $session->getCustomer()->getAddresses();
foreach (
$session->getCustomer()->getAddresses() as $address{
    
echo $address->getOrigData('postcode');
}

The address object contains two sets of addresses, called _origData and _data. If you need more information try using this:

$session Mage::getSingleton('customer/session');
$addresses $session->getCustomer()->getAddresses();

echo 
'<pre>';
die(
print_r($addresses));

Hope it helps smile, and happy christmas!

 
Magento Community Magento Community
Magento Community
Magento Community
 
pankajk
Member
 
Avatar
Total Posts:  38
Joined:  2008-04-15
Mumbai -101, Maharastra, India
 

Thanks for your reply, I got my solution for spliting street addresses of customer at checkout here I’m giving what I use to get a splited addresses :

$customerData = array();
$checkaddress=array();
$addressArrayObj Mage::getModel('paypal/standard');
$checkaddress $addressArrayObj->getStandardCheckoutFormFields(); //returns array of customer information with separated street addresses
$customerData['street1'$checkaddress['address1']
$customerData['street2'$checkaddress['address2'];
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top