1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26:
27: 28: 29: 30: 31: 32: 33:
34: class Mage_Adminhtml_Block_Tag_Grid_All extends Mage_Adminhtml_Block_Widget_Grid
35: {
36: public function __construct()
37: {
38: parent::__construct();
39: $this->setId('tagsGrid');
40: $this->setDefaultSort('tag_id', 'desc');
41: }
42:
43: protected function _prepareCollection()
44: {
45: $collection = Mage::getResourceModel('tag/tag_collection')
46:
47: ->addStoresVisibility()
48: ;
49: $this->setCollection($collection);
50: return parent::_prepareCollection();
51: }
52:
53: protected function _prepareColumns()
54: {
55: $this->addColumn('name', array(
56: 'header' => Mage::helper('tag')->__('Tag'),
57: 'index' => 'name',
58: ));
59: $this->addColumn('total_used', array(
60: 'header' => Mage::helper('tag')->__('# of Uses'),
61: 'width' => '140px',
62: 'align' => 'center',
63: 'index' => 'total_used',
64: 'type' => 'number',
65: ));
66: $this->addColumn('status', array(
67: 'header' => Mage::helper('tag')->__('Status'),
68: 'width' => '90px',
69: 'index' => 'status',
70: 'type' => 'options',
71: 'options' => array(
72: Mage_Tag_Model_Tag::STATUS_DISABLED => Mage::helper('tag')->__('Disabled'),
73: Mage_Tag_Model_Tag::STATUS_PENDING => Mage::helper('tag')->__('Pending'),
74: Mage_Tag_Model_Tag::STATUS_APPROVED => Mage::helper('tag')->__('Approved'),
75: ),
76: ));
77:
78:
79:
80: $this->setColumnFilter('id')
81: ->setColumnFilter('name')
82: ->setColumnFilter('total_used')
83: ;
84:
85: return parent::_prepareColumns();
86: }
87:
88: protected function _addColumnFilterToCollection($column)
89: {
90: if ($this->getCollection() && $column->getFilter()->getValue()) {
91: if($column->getIndex()=='stores') {
92: $this->getCollection()->addAttributeToFilter( $column->getIndex(), $column->getFilter()->getCondition());
93: } else {
94: $this->getCollection()->addStoreFilter($column->getFilter()->getCondition());
95: }
96: }
97: return $this;
98: }
99:
100: public function getRowUrl($row)
101: {
102: return $this->getUrl('*/*/products', array('tag_id' => $row->getId()));
103: }
104:
105: }
106: