2015-07-13 69 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') 
    ;