2015-07-13 67 views
0

我正在通过性别和姓名收集客户集合。我需要根据国家/地区ID添加过滤器,但需要在地址收集中查找每个客户的国家/地区ID。按国家筛选客户集合ID

$collection = Mage::getModel('customer/customer')->getCollection() 
     ->addAttributeToSelect('*'); 
     ->addAttributeToFilter('firstname', $post['firstname']); 
     ->addAttributeToFilter('gender', $post['gender']); 
     ->load(); 

所以我需要的东西是这样的:

$collection = Mage::getModel('customer/customer')->getCollection() 
     ->addAttributeToSelect('*'); 
     ->addAttributeToFilter('firstname', $post['firstname']); 
     ->addAttributeToFilter('gender', $post['gender']); 

     ->addAttributeToFilter('country_id', $post['country_id']);//US 
     ->load(); 
+0

请接受的答案,如果你觉得有用 –

回答

0
$collection = Mage::getResourceModel('customer/customer_collection') 
    ->joinAttribute('billing_country_id', 'customer_address/country_id', 'default_billing', null, 'left') 
    ->addFieldToFilter('billing_country_id','US') 
    ;