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

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -