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_Report_Tag_Product_Grid extends Mage_Adminhtml_Block_Widget_Grid
35: {
36:
37: public function __construct()
38: {
39: parent::__construct();
40: $this->setId('gridProducts');
41: }
42:
43: protected function _prepareCollection()
44: {
45:
46: $collection = Mage::getResourceModel('reports/tag_product_collection');
47:
48: $collection->addUniqueTagedCount()
49: ->addAllTagedCount()
50: ->addStatusFilter(Mage::getModel('tag/tag')->getApprovedStatus())
51: ->addGroupByProduct();
52:
53: $this->setCollection($collection);
54: return parent::_prepareCollection();
55: }
56:
57: protected function _prepareColumns()
58: {
59:
60: $this->addColumn('entity_id', array(
61: 'header' =>Mage::helper('reports')->__('ID'),
62: 'width' =>'50px',
63: 'align' =>'right',
64: 'index' =>'entity_id'
65: ));
66:
67: $this->addColumn('name', array(
68: 'header' =>Mage::helper('reports')->__('Product Name'),
69: 'index' =>'name'
70: ));
71:
72: $this->addColumn('utaged', array(
73: 'header' =>Mage::helper('reports')->__('Number of Unique Tags'),
74: 'width' =>'50px',
75: 'align' =>'right',
76: 'index' =>'utaged'
77: ));
78:
79: $this->addColumn('taged', array(
80: 'header' =>Mage::helper('reports')->__('Number of Total Tags'),
81: 'width' =>'50px',
82: 'align' =>'right',
83: 'index' =>'taged'
84: ));
85:
86: $this->addColumn('action',
87: array(
88: 'header' => Mage::helper('catalog')->__('Action'),
89: 'width' => '100%',
90: 'type' => 'action',
91: 'getter' => 'getId',
92: 'actions' => array(
93: array(
94: 'caption' => Mage::helper('catalog')->__('Show Tags'),
95: 'url' => array(
96: 'base'=>'*/*/productDetail'
97: ),
98: 'field' => 'id'
99: )
100: ),
101: 'is_system' => true,
102: 'filter' => false,
103: 'sortable' => false,
104: 'index' => 'stores',
105: ));
106:
107: $this->setFilterVisibility(false);
108:
109: $this->addExportType('*/*/exportProductCsv', Mage::helper('reports')->__('CSV'));
110: $this->addExportType('*/*/exportProductExcel', Mage::helper('reports')->__('Excel XML'));
111:
112: return parent::_prepareColumns();
113: }
114:
115: public function getRowUrl($row)
116: {
117: return $this->getUrl('*/*/productDetail', array('id'=>$row->getId()));
118: }
119:
120: }
121: