Display different table values as a column in grid in admin of magento.
I have to add one field for displaying ‘custom_id’, ‘status’, ‘send_date’ field as a columns in customer grid.
//Customer grid collection
$collection = Mage::getResourceModel('customer/customer_collection')
->addNameToSelect()
->addAttributeToSelect('email')
->addAttributeToSelect('created_at')
->addAttributeToSelect('group_id');
$this->setCollection($collection);
$collection->getSelect()->joinLeft(array('gf'=>'giftcard'),
'gf.customer_id = e.entity_id',
array(
'rule_id'=> 'gf.custom_id',
'status' => 'IF(gf.status IS NULL,"Unsend","Send")',
'send_date' => 'gf.created_time'
))
->group('e.entity_id');
//To add column
Add below
$this->addColumn('created_time', array(
'header' => Mage::helper('giftcard')->__('Coupon Send Date'),
'align' => 'left',
'index' => 'send_date',
'type' => 'datetime',
'gmtoffset' => true
));
I hope this will help you..
If this post is help you than please do reply
thanks
Abhay
I have to add one field for displaying ‘custom_id’, ‘status’, ‘send_date’ field as a columns in customer grid.
//Customer grid collection
$collection = Mage::getResourceModel('customer/customer_collection')
->addNameToSelect()
->addAttributeToSelect('email')
->addAttributeToSelect('created_at')
->addAttributeToSelect('group_id');
$this->setCollection($collection);
$collection->getSelect()->joinLeft(array('gf'=>'giftcard'),
'gf.customer_id = e.entity_id',
array(
'rule_id'=> 'gf.custom_id',
'status' => 'IF(gf.status IS NULL,"Unsend","Send")',
'send_date' => 'gf.created_time'
))
->group('e.entity_id');
//To add column
Add below
$this->addColumn('created_time', array(
'header' => Mage::helper('giftcard')->__('Coupon Send Date'),
'align' => 'left',
'index' => 'send_date',
'type' => 'datetime',
'gmtoffset' => true
));
I hope this will help you..
If this post is help you than please do reply
thanks
Abhay
Comments
Post a Comment
Feel Free To Ask...