Magento get customer by Tax/VAT number field -
i looking similar 1 (thats works email), instead of customer email, want him tax/vat number.
$customer = mage::getmodel('customer/customer')->setwebsiteid($website->getwebsiteid())->loadbyemail($customeremail);
i found example doesn't work.
$customer = mage::getmodel('customer/customer')->getcollection()->addattributetoselect('*')->addfieldtofilter('taxvat', $ss_5_last)->load();
thank you.
if attribute taxvat contains unique values, approach right. result of second try returns collection. think need customer object, try one:
$customer = mage::getmodel('customer/customer') ->getcollection() ->addattributetoselect('*') ->addfieldtofilter('taxvat', $ss_5_last) ->getfirstitem();
this returns customer object can work with. caution: if taxvat not contain unique values, method return wrong customer, because returns first item of collection more 1 item.
Comments
Post a Comment