In Magento i want to search the customer with the address(state,city,zipcode), can you explain to me how to the achieve that.
The customer collection query
$collection = Mage::getModel('customer/customer')->getCollection();
$collection->addAttributeToSelect(array('userid','firstname','lastname','profile_image','specialist','latitude','free_consult','longitude'));
$collection->addAttributeToFilter('group_id',Federallawyer_Customer_Helper_Data::LAWYER);
also my shipping and billing address is same.
Pradeep Sanku
9,2662 gold badges42 silver badges75 bronze badges
asked Jul 15, 2015 at 11:06
senthil
1,7372 gold badges28 silver badges59 bronze badges
1 Answer 1
$collection = Mage::getModel('customer/customer')->getCollection()
->joinAttribute('billing_postcode', 'customer_address/postcode', '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_postcode','123456') // replace with your post code
->addFieldToFilter('billing_city','test') // replace with your city
->addFieldToFilter('billing_region','test') // replace with your region
answered Jul 15, 2015 at 11:14
Keyur Shah
18.1k6 gold badges68 silver badges80 bronze badges
Explore related questions
See similar questions with these tags.
default