Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Magento按税务/增值税编号获取客户字段_Magento_Magento 1.9 - Fatal编程技术网

Magento按税务/增值税编号获取客户字段

Magento按税务/增值税编号获取客户字段,magento,magento-1.9,Magento,Magento 1.9,我正在寻找与此类似的东西(它与电子邮件一起工作),但我不想通过电子邮件联系客户,而是想通过税务/增值税号码联系客户 $customer = Mage::getModel('customer/customer')->setWebsiteId($website->getWebsiteId())->loadByEmail($customerEmail); 我找到了这个例子,但它不起作用 $customer = Mage::getModel('customer/customer')-

我正在寻找与此类似的东西(它与电子邮件一起工作),但我不想通过电子邮件联系客户,而是想通过税务/增值税号码联系客户

$customer = Mage::getModel('customer/customer')->setWebsiteId($website->getWebsiteId())->loadByEmail($customerEmail);
我找到了这个例子,但它不起作用

$customer = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('*')->addFieldToFilter('taxvat',  $ss_5_last)->load();
谢谢。

如果属性taxvat包含唯一的值,那么您的方法几乎是正确的。但是第二次尝试的结果返回一个集合。我认为您需要一个客户对象,因此请尝试以下方法:

$customer = Mage::getModel('customer/customer')
            ->getCollection()
            ->addAttributeToSelect('*')
            ->addFieldToFilter('taxvat',  $ss_5_last)
            ->getFirstItem();
这将返回您可以使用的客户对象。警告:如果taxvat不包含唯一值,此方法可能返回错误的客户,因为它总是返回包含多个项目的集合的第一个项目