Magento读取客户国家/地区

Magento读取客户国家/地区,magento,Magento,如何阅读客户国家/地区?我试过这个: $collection = Mage::getModel('customer/customer')->getCollection() ->addAttributeToSelect('firstname') ->addAttributeToSelect('lastname') ->addAttributeToSelect('email'); 但是我找不到客户国家/地区、州等属性在第一行代码中加载您的客户地址ID,您最终将获得以下详细信

如何阅读客户国家/地区?我试过这个:

$collection = Mage::getModel('customer/customer')->getCollection()
->addAttributeToSelect('firstname')
->addAttributeToSelect('lastname')
->addAttributeToSelect('email');

但是我找不到客户国家/地区、州等属性

在第一行代码中加载您的客户地址ID,您最终将获得以下详细信息:

    $address = Mage::getModel('customer/address')->load($customerAddressId);
    $fullname = $customer->getName();
    $firstname = $customer->getFirstname();
    $lastname = $customer->getLastname();
    $email = $customer->getEmail();
    $taxvat = $customer->getTaxvat();
    $tele = $customer->getTelephone();
    $telephone = $address->getTelephone();
    $street = $address->getStreet();
    $City = $address->getCity();
    $region = $address->getRegion();
    $postcode = $address->getPostcode();
试试这个

<?php

require_once('app/Mage.php'); //Path to Magento
umask(0);
Mage::app();


$customerId = 136;

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

$customerAddress = array();
#loop to create the array
foreach ($customer->getAddresses() as $address)
{
    $customerAddress = $address->toArray();
}

/* echo '<pre/>';
print_r($customerAddress );
 */
$country_id = $customerAddress['country_id'];

$countryModel = Mage::getModel('directory/country')->loadByCode($country_id);
echo $countryName = $countryModel->getName();

在你的帮助下,我做到了:

        $collection = Mage::getModel('customer/customer')->getCollection()
            ->addAttributeToSelect('entity_id')
            ->addAttributeToSelect('firstname')
            ->addAttributeToSelect('lastname')
            ->addAttributeToSelect('email');

        foreach ($collection as $item) {
            $row = $item->getData();

                $customerId = $row['entity_id'];
                $customer = Mage::getModel('customer/customer')->load($customerId);

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

                $country = Mage::app()->getLocale()->getCountryTranslation( $customerAddress['country_id']);
                $state = $customerAddress['region'];

        }