显示用户 alhpabebe 在洋红色中



嗨,我已经在前端获取用户并使用下面的一些属性过滤它们

$userid =  Mage::getSingleton('customer/session')->getId();
$customer = Mage::getModel("customer/customer")->getCollection()->addAttributeToFilter('main_supplier',$userid)
->load();

这工作正常,但是

我需要按字母顺序显示用户

你能建议我该怎么做吗,请建议

谢谢

我假设您有多个记录,其中main_supplier的用户是多个,

只需添加下面的查询和集合,即可从客户模型中从他/她的名字中对用户进行排序

$model = Mage::getSingleton('customer/customer');
$result = $model->getCollection()
        ->addAttributeToSelect('*')
         ->addAttributeToFilter('main_supplier', array('eq' => $userid))
          ->addAttributeToSort('firstname', 'ASC');
foreach($result as $r) 
{       
        $customer = $model->load($r->getId());
        echo PHP_EOL,'<b>'.$customer->getFirstname().' '.$customer->getLastname().' '.$customer->getEmail(),PHP_EOL;
}

上面的例子对我有用,希望这肯定会对您有所帮助。

让我知道我是否可以进一步帮助您。

最新更新