2013-11-28 24 views
0

如你所知,在数据库中,newsletter_subscriber表已经CUSTOMER_ID列如何从用户的Magento得到客户群

在管理通讯用户的网格,我加列客户群这样

$this->addColumn('customer_group', array(
     'header' => Mage::helper('newsletter')->__('Customer Group'), 
     'index'  => 'customer_group' 

    )); 

因此,如何能从订户中的customer_id获取客户组?

THKS

回答

1

修改最后几行中protected function _prepareCollection()方法

$collection->getSelect()->join(array('ce'=>'customer_entity'),'ce.entity_id=main_table.customer_id',array('ce.group_id')); 
$collection->getSelect()->join(array('cg'=>'customer_group'),'cg.customer_group_id=ce.group_id',array('cg.customer_group_code')); 
$this->setCollection($collection); 

然后添加字段这样

$this->addColumn('customer_group_code', array(
     'header' => Mage::helper('newsletter')->__('Customer Group'), 
     'index'  => 'customer_group_code' 
    ));