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:
35: class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Tag extends Mage_Adminhtml_Block_Widget_Grid
36: {
37: public function __construct()
38: {
39: parent::__construct();
40: $this->setId('tag_grid');
41: $this->setDefaultSort('name');
42: $this->setDefaultDir('ASC');
43: $this->setUseAjax(true);
44: }
45:
46: protected function _prepareCollection()
47: {
48: $collection = Mage::getModel('tag/tag')
49: ->getResourceCollection()
50: ->addProductFilter($this->getProductId())
51: ->addPopularity();
52:
53: $this->setCollection($collection);
54: return parent::_prepareCollection();
55: }
56:
57: protected function _afterLoadCollection()
58: {
59: return parent::_afterLoadCollection();
60: }
61:
62: protected function _prepareColumns()
63: {
64: $this->addColumn('name', array(
65: 'header' => Mage::helper('catalog')->__('Tag Name'),
66: 'index' => 'name',
67: ));
68:
69: $this->addColumn('popularity', array(
70: 'header' => Mage::helper('catalog')->__('# of Use'),
71: 'width' => '50px',
72: 'align' => 'right',
73: 'index' => 'popularity',
74: 'type' => 'number',
75: ));
76:
77: $this->addColumn('status', array(
78: 'header' => Mage::helper('catalog')->__('Status'),
79: 'width' => '90px',
80: 'index' => 'status',
81: 'type' => 'options',
82: 'options' => array(
83: Mage_Tag_Model_Tag::STATUS_DISABLED => Mage::helper('catalog')->__('Disabled'),
84: Mage_Tag_Model_Tag::STATUS_PENDING => Mage::helper('catalog')->__('Pending'),
85: Mage_Tag_Model_Tag::STATUS_APPROVED => Mage::helper('catalog')->__('Approved'),
86: ),
87: ));
88:
89: return parent::_prepareColumns();
90: }
91:
92: public function getRowUrl($row)
93: {
94: return $this->getUrl('*/tag/edit', array(
95: 'tag_id' => $row->getId(),
96: 'product_id' => $this->getProductId(),
97: ));
98: }
99:
100: public function getGridUrl()
101: {
102: return $this->getUrl('*/catalog_product/tagGrid', array(
103: '_current' => true,
104: 'id' => $this->getProductId(),
105: 'product_id' => $this->getProductId(),
106: ));
107: }
108: }
109: