加入集合以获取客户名称(对于管理网格)

use*_*125 6 magento

我有一个自定义模块的表,其中包含以下列:

---------------
| custom_table|
---------------
| id
| seller_id
| buyer_id
| ...
---------------

seller_id -> customer_enity [entity_id]
buyer_id -> customer_entity [entity_id]
Run Code Online (Sandbox Code Playgroud)

现在我想在管理网格布局中显示卖家名称和买家名称.我无法弄清楚如何从客户实体中检索卖家名称和买家名称.但我知道如何检索他们的电子邮件:

protected function _prepareCollection()
{
  $collection = Mage::getModel('custommodule/custommodule')->getCollection();  
  $collection->getSelect()
        ->join( array('ce1' => 'customer_entity'), 'ce1.entity_id=main_table.seller_id', array('seller_email' => 'email'))
        ->join( array('ce2' => 'customer_entity'), 'ce2.entity_id=main_table.buyer_id', array('buyer_email' => 'email'));
  #echo $collection->getSelect()->__toString();
  $this->setCollection($collection);
  return parent::_prepareCollection();
}
Run Code Online (Sandbox Code Playgroud)

以上代码工作正常.但我想显示他们的名字而不是电子邮件.任何人都可以帮我修改这个系列吗?

很感谢任何形式的帮助.谢谢

Cas*_*Roy 3

您需要加入名称为store的customer_entity_varchar表,
并且attribute_id = 5, 5因为它是所有属性都存储的表eav_attribute中属性名称的id
希望它对您有帮助