Magento 1.9 – How to Retrieve All Customer Data

collection;customercustomer-attributemagento-1.9

I want to retrieve all customer data including the address information, customer custom attributes, and customer profile information. Right now i'm using customer model like this:

$collections = Mage::getModel('customer/customer')->getCollection();
foreach ($collections as $collection) {
            $result[]= $collection->getData();
}
print_r($result);

form this i only get basic information like entity_id, store_id, created_at, is_active, and etc. by using this i can't get even the customer personal information like telephone or at least customer name

Best Answer

you can get the customer details like below :

customer id here

$customerId = 1;

load customer object

$customer = Mage::getModel('customer/customer')->load($customerId); //insert cust ID

create customer address array

$customerAddress = array();
foreach ($customer->getAddresses() as $address)
{
   $customerAddress[] = $address->toArray();
}

displaying the array

echo '<pre/>';print_r($customerAddress);exit;

After getting the user’s address you will see something like this:

Array
(
    [entity_id] => 1
    [entity_type_id] => 2
    [attribute_set_id] => 0
    [increment_id] => 
    [parent_id] => 1
    [created_at] => 2013-12-05 14:28:40
    [updated_at] => 2013-12-05 16:14:13
    [is_active] => 1
    [firstname] => Daniel
    [lastname] => Halmagean
    [city] => New York
    [region] => New Jersey
    [postcode] => 123123
    [country_id] => RO
    [telephone] => 2342423434243
    [region_id] => 282
    [street] => my street name
    [customer_id] => 1
)
Related Topic