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_All extends Mage_Adminhtml_Block_Widget_Grid
00035 {
00036 public function __construct()
00037 {
00038 parent::__construct();
00039 $this->setId('tagsGrid');
00040 $this->setDefaultSort('tag_id', 'desc');
00041 }
00042
00043 protected function _prepareCollection()
00044 {
00045 $collection = Mage::getResourceModel('tag/tag_collection')
00046
00047 ->addStoresVisibility()
00048 ;
00049 $this->setCollection($collection);
00050 return parent::_prepareCollection();
00051 }
00052
00053 protected function _prepareColumns()
00054 {
00055 $this->addColumn('name', array(
00056 'header' => Mage::helper('tag')->__('Tag'),
00057 'index' => 'name',
00058 ));
00059 $this->addColumn('total_used', array(
00060 'header' => Mage::helper('tag')->__('# of Uses'),
00061 'width' => '140px',
00062 'align' => 'center',
00063 'index' => 'total_used',
00064 'type' => 'number',
00065 ));
00066 $this->addColumn('status', array(
00067 'header' => Mage::helper('tag')->__('Status'),
00068 'width' => '90px',
00069 'index' => 'status',
00070 'type' => 'options',
00071 'options' => array(
00072 Mage_Tag_Model_Tag::STATUS_DISABLED => Mage::helper('tag')->__('Disabled'),
00073 Mage_Tag_Model_Tag::STATUS_PENDING => Mage::helper('tag')->__('Pending'),
00074 Mage_Tag_Model_Tag::STATUS_APPROVED => Mage::helper('tag')->__('Approved'),
00075 ),
00076 ));
00077
00078
00079
00080 $this->setColumnFilter('id')
00081 ->setColumnFilter('name')
00082 ->setColumnFilter('total_used')
00083 ;
00084
00085 return parent::_prepareColumns();
00086 }
00087
00088 protected function _addColumnFilterToCollection($column)
00089 {
00090 if ($this->getCollection() && $column->getFilter()->getValue()) {
00091 if($column->getIndex()=='stores') {
00092 $this->getCollection()->addAttributeToFilter( $column->getIndex(), $column->getFilter()->getCondition());
00093 } else {
00094 $this->getCollection()->addStoreFilter($column->getFilter()->getCondition());
00095 }
00096 }
00097 return $this;
00098 }
00099
00100 public function getRowUrl($row)
00101 {
00102 return $this->getUrl('*/*/products', array('tag_id' => $row->getId()));
00103 }
00104
00105 }