I'd like to filter my collection using something like:

  ->setValue('(555) 229-3326')

But the telephone attribute is an attribute on Default Billing Address, how can I do that?

  • You only need customer where telephone = "value" ? or Want customer from orders – Sourav Mar 29 '18 at 3:19
  • I need to get the customer where telephone="value" – Rafael Corrêa Gomes Mar 29 '18 at 14:23

You can add default address telephone to collection by add joinAttribute() to collection.

 ->joinAttribute('billing_telephone', 'customer_address/telephone', 'default_billing', null, 'left')
 ->addAttributeToFilter('billing_telephone','(555) 229-3326');
| improve this answer | |
  • What a bad mistake.i did.Thanks to Rafeal – Amit Bera Mar 30 '18 at 7:59

You can get customer using Join on customer collection.

$collection->getSelect()->join(array('billing'=>'sales_flat_order_address'), 'e.entity_id = billing.customer_id',array('telephone' =>'telephone') )->where("billing.address_type =  'billing'  AND billing.telephone = '(555) 229-3326'");     

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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