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_Grid_Customers extends Mage_Adminhtml_Block_Widget_Grid
00035 {
00036 protected function _prepareCollection()
00037 {
00038
00039 $collection = Mage::getResourceModel('tag_customer/collection')
00040 ->addAttributeToSelect('firstname')
00041 ->addAttributeToSelect('lastname')
00042
00043
00044
00045
00046
00047
00048
00049 ;
00050
00051 if ($productId = $this->getRequest()->getParam('product_id')) {
00052 $collection->addProductFilter($productId);
00053 }
00054 if ($tagId = $this->getRequest()->getParam('tag_id')) {
00055 $collection->addTagFilter($tagId);
00056 }
00057
00058 $this->setCollection($collection);
00059
00060 return parent::_prepareCollection();
00061 }
00062
00063 protected function _prepareColumns()
00064 {
00065 $this->addColumn('entity_id', array(
00066 'header' =>Mage::helper('tag')->__('ID'),
00067 'width' => '40px',
00068 'align' =>'center',
00069 'sortable' =>true,
00070 'index' =>'entity_id'
00071 ));
00072 $this->addColumn('firstname', array(
00073 'header' =>Mage::helper('tag')->__('First Name'),
00074 'index' =>'firstname'
00075 ));
00076 $this->addColumn('lastname', array(
00077 'header' =>Mage::helper('tag')->__('Last Name'),
00078 'index' =>'lastname'
00079 ));
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106 $this->addColumn('tags', array(
00107 'header' => Mage::helper('tag')->__('Tags'),
00108 'index' => 'tags',
00109 'sortable' => false,
00110 'filter' => false,
00111 'renderer' => 'adminhtml/tag_grid_column_renderer_tags'
00112 ));
00113 $this->addColumn('action', array(
00114 'header' =>Mage::helper('tag')->__('Action'),
00115 'align' =>'center',
00116 'width' => '120px',
00117 'format' =>'<a href="'.$this->getUrl('*/*/products/customer_id/$entity_id').'">'.Mage::helper('tag')->__('View Products').'</a>',
00118 'filter' =>false,
00119 'sortable' =>false,
00120 'is_system' =>true
00121 ));
00122
00123 $this->setColumnFilter('entity_id')
00124 ->setColumnFilter('email')
00125 ->setColumnFilter('firstname')
00126 ->setColumnFilter('lastname');
00127
00128
00129
00130 return parent::_prepareColumns();
00131 }
00132
00133 protected function _addColumnFilterToCollection($column)
00134 {
00135 if ($this->getCollection() && $column->getFilter()->getValue()) {
00136 $this->getCollection()->addAttributeToFilter($column->getIndex(), $column->getFilter()->getCondition());
00137 }
00138 return $this;
00139 }
00140
00141 }