2013-04-24 43 views
1

我想根据他们的状态明智地获取所有客户的详细信息,例如收集来自亚利桑那州的所有客户。未在Magento块文件中获取客户收藏?

代码:

$collection = array(); 
$collection = Mage::getResourceModel('customer/customer_collection') 
    ->joinAttribute('company', 'customer_address/company', 'default_billing', null, 'left') 
    ->joinAttribute('billing_city', 'customer_address/city', 'default_billing', null, 'left') 
    ->joinAttribute('billing_region', 'customer_address/region', 'default_billing', null, 'left') 
    ->addFieldToFilter('billing_region',$stateName) 
    ->setOrder('billing_city', 'asc'); 
echo $stateName; 
echo $collection->getSelect(); 
print_r($collection); 
return $collection; 

现在,当我显示查询和SQL运行它工作正常,但收集不显示任何内容。

任何帮助将不胜感激!!!!

+0

要显示这些记录在哪里? – 2013-04-24 06:02:13

+0

你是否包含'app/Mage.php'?就像我在这里回答我的答案:http://stackoverflow.com/questions/14743362 – 2013-04-25 00:13:56

回答

0

尝试加载集合:

->setOrder('billing_city', 'asc')->load();