Magento:通过自定义字段查询客户地址
我已经在客户地址中添加了一个自定义字段,但我不知道如何使用此字段进行查询 我正在执行以下代码: $collection=Mage::getModel('客户/地址') ->getCollection() ->addAttributeToSelect('custom_field') ->addFieldToFilter('custom_field','1'); echo var_dump($collection) 但我面临着这个错误: 致命错误:对中的非对象调用成员函数getBackend() 第816行的app\code\core\Mage\Eav\Model\Entity\Abstract.php 我的问题是:如何通过该字段进行查询 谢谢。尝试使用 Mage::getResourceModel('客户/地址\集合') 而不是 Mage::getModel('customer/address')->getCollection() 请参阅/app/code/core/Mage/Customer/Model/Customer.phpMagento:通过自定义字段查询客户地址,magento,magento-1.7,Magento,Magento 1.7,我已经在客户地址中添加了一个自定义字段,但我不知道如何使用此字段进行查询 我正在执行以下代码: $collection=Mage::getModel('客户/地址') ->getCollection() ->addAttributeToSelect('custom_field') ->addFieldToFilter('custom_field','1'); echo var_dump($collection) 但我面临着这个错误: 致命错误:对中的非对象调用成员函数getBackend() 第
$collection = Mage::getResourceModel('customer/address_collection')
->addAttributeToSelect('custom_field')
->addAttributeToFilter('custom_field', '1')
->getItems();
经过几次测试,我可以解决这个问题。代码如下:
$collection = Mage::getResourceModel('customer/address_collection')
->addAttributeToSelect('*')
->addAttributeToFilter('custom_field', 1)
->getItems();
echo print_r($collection, true);
感谢您的建议,但它没有起作用:/-我可以执行第一行,但当我尝试添加#2或3#行时,我提到的错误再次发生。还有别的想法吗?