所有客户的清单

时间:2015-02-21 02:36:34

标签: list magento

我想在我正在构建的自定义模块中创建所有客户的列表,但我似乎无法找出问题所在。我试过这个:

 public function getAllOptions($withEmpty = true, $defaultValues = false)
    {
    $source  = Mage::getModel('eav/config')->getAttribute('customer', 'firstname');
    return $source->getSource()->getAllOptions($withEmpty, $defaultValues);
}

但它给了我一个错误:

Source model "" not found for attribute "firstname"

#0 /var/www/c8do/app/code/core/Mage/Eav/Model/Entity/Attribute/Abstract.php(387): Mage::exception('Mage_Eav', 'Source model ""...')

当我尝试用性别替换名字时,它正常工作(给女性/男性)。

1 个答案:

答案 0 :(得分:2)

$collection = Mage::getModel('customer/customer')->getCollection()
   ->addAttributeToSelect('firstname')
   ->addAttributeToSelect('lastname')
   ->addAttributeToSelect('email');

如果您不需要姓名,姓氏或电子邮件,可以跳过这一行。