我按性别和姓名收集客户。我需要按国家/地区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')
;