1

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.

0

1 Answer 1

3
$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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.