简体   繁体   中英

how to get customer group from subscriber magento

As you know, in database, newsletter_subscriber table have customer_id column

In admin newsletter subscriber grid, i add column Customer Group like this

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

    ));

So how can get customer group from customer_id in subscriber?

thks

modify last lines in protected function _prepareCollection() method

$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);

and then add field like this

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM