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_Tag_Grid extends Mage_Adminhtml_Block_Widget_Grid
00035 {
00036
00037 public function __construct()
00038 {
00039 parent::__construct();
00040 $this->setId('tag_tag_grid');
00041 $this->setDefaultSort('name');
00042 $this->setDefaultDir('ASC');
00043 }
00044
00045 protected function _prepareCollection()
00046 {
00047 $collection = Mage::getResourceModel('tag/tag_collection')
00048 ->addSummary(0)
00049 ->addStoresVisibility();
00050 $this->setCollection($collection);
00051 return parent::_prepareCollection();
00052 }
00053
00054 protected function _prepareColumns()
00055 {
00056 $baseUrl = $this->getUrl();
00057
00058 $this->addColumn('name', array(
00059 'header' => Mage::helper('tag')->__('Tag'),
00060 'index' => 'name',
00061 ));
00062
00063 $this->addColumn('total_used', array(
00064 'header' => Mage::helper('tag')->__('Uses'),
00065 'width' => '140px',
00066 'align' => 'right',
00067 'index' => 'uses',
00068 'type' => 'number',
00069 ));
00070
00071 $this->addColumn('products', array(
00072 'header' => Mage::helper('tag')->__('Products'),
00073 'width' => '140px',
00074 'align' => 'right',
00075 'index' => 'products',
00076 'type' => 'number',
00077 ));
00078
00079 $this->addColumn('customers', array(
00080 'header' => Mage::helper('tag')->__('Customers'),
00081 'width' => '140px',
00082 'align' => 'right',
00083 'index' => 'customers',
00084 'type' => 'number',
00085 ));
00086
00087 $this->addColumn('popularity', array(
00088 'header' => Mage::helper('tag')->__('Popularity'),
00089 'width' => '140px',
00090 'align' => 'right',
00091 'index' => 'popularity',
00092 'type' => 'number',
00093 ));
00094
00095 $this->addColumn('status', array(
00096 'header' => Mage::helper('tag')->__('Status'),
00097 'width' => '90px',
00098 'index' => 'status',
00099 'type' => 'options',
00100 'options' => $this->helper('tag/data')->getStatusesArray(),
00101 ));
00102
00103 if (!Mage::app()->isSingleStoreMode()) {
00104 $this->addColumn('visible_in', array(
00105 'header' => Mage::helper('tag')->__('Visible In'),
00106 'type' => 'store',
00107 'skipAllStoresLabel' => true,
00108 'index' => 'stores',
00109 'sortable' => false,
00110 'store_view'=> true
00111 ));
00112 }
00113
00114 $this->addColumn('actions', array(
00115 'header' => Mage::helper('tag')->__('Actions'),
00116 'width' => '100px',
00117 'type' => 'action',
00118 'getter' => 'getId',
00119 'sortable' => false,
00120 'filter' => false,
00121 'actions' => array(
00122 array(
00123 'caption' => Mage::helper('tag')->__('Edit Tag'),
00124 'url' => $this->getUrl('*/*/edit', array('ret' => 'all', 'tag_id'=>'$tag_id')),
00125 ),
00126 array(
00127 'caption' => Mage::helper('tag')->__('View Products'),
00128 'url' => $this->getUrl('*/*/product', array('ret' => 'all', 'tag_id'=>'$tag_id')),
00129 ),
00130
00131 array(
00132 'caption' => Mage::helper('tag')->__('View Customers'),
00133 'url' => $this->getUrl('*/*/customer', array('ret' => 'all', 'tag_id'=>'$tag_id')),
00134 )
00135 ),
00136 ));
00137
00138 return parent::_prepareColumns();
00139 }
00140
00141 public function getRowUrl($row)
00142 {
00143 return $this->getUrl('*/*/edit', array(
00144 'tag_id' => $row->getId(),
00145 'ret' => 'all',
00146 ));
00147 }
00148
00149 protected function _addColumnFilterToCollection($column)
00150 {
00151 if($column->getIndex()=='stores') {
00152 $this->getCollection()->addStoreFilter($column->getFilter()->getCondition(), false);
00153 } else {
00154 parent::_addColumnFilterToCollection($column);
00155 }
00156
00157 return $this;
00158 }
00159
00160 protected function _prepareMassaction()
00161 {
00162 $this->setMassactionIdField('tag_id');
00163 $this->getMassactionBlock()->setFormFieldName('tag');
00164
00165 $this->getMassactionBlock()->addItem('delete', array(
00166 'label'=> Mage::helper('tag')->__('Delete'),
00167 'url' => $this->getUrl('*/*/massDelete'),
00168 'confirm' => Mage::helper('tag')->__('Are you sure?')
00169 ));
00170
00171 $statuses = $this->helper('tag/data')->getStatusesOptionsArray();
00172
00173 array_unshift($statuses, array('label'=>'', 'value'=>''));
00174
00175 $this->getMassactionBlock()->addItem('status', array(
00176 'label'=> Mage::helper('tag')->__('Change status'),
00177 'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
00178 'additional' => array(
00179 'visibility' => array(
00180 'name' => 'status',
00181 'type' => 'select',
00182 'class' => 'required-entry',
00183 'label' => Mage::helper('tag')->__('Status'),
00184 'values' => $statuses
00185 )
00186 )
00187 ));
00188
00189 return $this;
00190 }
00191
00192 }
00193