List 所有客户名单

List 所有客户名单,list,magento,List,Magento,我想在我正在构建的自定义模块中创建一个所有客户的列表,但我似乎无法找出问题所在。我试过这个: public function getAllOptions($withEmpty = true, $defaultValues = false) { $source = Mage::getModel('eav/config')->getAttribute('customer', 'firstname'); return $source->getSource()-&

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

 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 ""...')
当我试图用性别来代替名字时,它工作正常(给出女性/男性)


如果不需要firstname、lastname或email,可以跳过这一行。

这是指定属性值的第二个参数。下面的答案适合你的情况。
$collection = Mage::getModel('customer/customer')->getCollection()
   ->addAttributeToSelect('firstname')
   ->addAttributeToSelect('lastname')
   ->addAttributeToSelect('email');