00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 class Mage_Adminhtml_Block_Tag_Customer_Grid extends Mage_Adminhtml_Block_Widget_Grid
00035 {
00036
00037 public function __construct()
00038 {
00039 parent::__construct();
00040 $this->setId('tag_grid' . Mage::registry('tagId'));
00041 $this->setDefaultSort('name');
00042 $this->setDefaultDir('ASC');
00043 }
00044
00045 protected function _prepareCollection()
00046 {
00047 $tagId = Mage::registry('tagId');
00048 $collection = Mage::getModel('tag/tag')
00049 ->getCustomerCollection()
00050 ->addTagFilter($tagId)
00051 ->setCountAttribute('tr.tag_relation_id')
00052 ->addGroupByCustomerProduct();
00053
00054 $this->setCollection($collection);
00055 return parent::_prepareCollection();
00056 }
00057
00058 protected function _afterLoadCollection()
00059 {
00060 $this->getCollection()->addProductName();
00061 return parent::_afterLoadCollection();
00062 }
00063
00064 protected function _prepareColumns()
00065 {
00066 $this->addColumn('customer_id', array(
00067 'header' => Mage::helper('tag')->__('ID'),
00068 'width' => '50px',
00069 'align' => 'right',
00070 'index' => 'entity_id',
00071 ));
00072
00073 $this->addColumn('firstname', array(
00074 'header' => Mage::helper('tag')->__('First Name'),
00075 'index' => 'firstname',
00076 ));
00077
00078 $this->addColumn('lastname', array(
00079 'header' => Mage::helper('tag')->__('Last Name'),
00080 'index' => 'lastname',
00081 ));
00082
00083 if (!Mage::app()->isSingleStoreMode()) {
00084 $this->addColumn('store_id', array(
00085 'header' => Mage::helper('tag')->__('Tagged in'),
00086 'index' => 'store_id',
00087 'type' => 'store',
00088 'store_view' => true,
00089 ));
00090 }
00091
00092 $this->addColumn('product', array(
00093 'header' => Mage::helper('tag')->__('Product Name'),
00094 'filter' => false,
00095 'sortable' => false,
00096 'index' => 'product',
00097 ));
00098
00099 $this->addColumn('product_sku', array(
00100 'header' => Mage::helper('tag')->__('Product SKU'),
00101 'filter' => false,
00102 'sortable' => false,
00103 'width' => '50px',
00104 'align' => 'right',
00105 'index' => 'product_sku',
00106 ));
00107
00108 $this->addColumn('product_sku', array(
00109 'header' => Mage::helper('tag')->__('Product SKU'),
00110 'filter' => false,
00111 'sortable' => false,
00112 'width' => '50px',
00113 'align' => 'right',
00114 'index' => 'product_sku',
00115 ));
00116
00117 return parent::_prepareColumns();
00118 }
00119
00120 protected function getRowUrl($row)
00121 {
00122 return $this->getUrl('*/customer/edit', array('id' => $row->getCustomerId()));
00123 }
00124
00125 }