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_Popular_Grid extends Mage_Adminhtml_Block_Widget_Grid
35: {
36:
37: public function __construct()
38: {
39: parent::__construct();
40: $this->setId('grid');
41: }
42:
43: protected function _prepareCollection()
44: {
45:
46: if ($this->getRequest()->getParam('website')) {
47: $storeId = Mage::app()->getWebsite($this->getRequest()->getParam('website'))->getStoreIds();
48: } else if ($this->getRequest()->getParam('group')) {
49: $storeId = Mage::app()->getGroup($this->getRequest()->getParam('group'))->getStoreIds();
50: } else if ($this->getRequest()->getParam('store')) {
51: $storeId = (int)$this->getRequest()->getParam('store');
52: } else {
53: $storeId = '';
54: }
55:
56: $collection = Mage::getResourceModel('reports/tag_collection')
57: ->addPopularity($storeId)
58: ->addStatusFilter(Mage_Tag_Model_Tag::STATUS_APPROVED);
59:
60: $this->setCollection($collection);
61: return parent::_prepareCollection();
62: }
63:
64: protected function _prepareColumns()
65: {
66: $this->addColumn('name', array(
67: 'header' =>Mage::helper('reports')->__('Tag Name'),
68: 'sortable' =>false,
69: 'index' =>'name'
70: ));
71:
72: $this->addColumn('taged', array(
73: 'header' =>Mage::helper('reports')->__('Popularity'),
74: 'width' =>'50px',
75: 'align' =>'right',
76: 'sortable' =>false,
77: 'index' =>'popularity'
78: ));
79:
80: $this->addColumn('action',
81: array(
82: 'header' => Mage::helper('catalog')->__('Action'),
83: 'width' => '100%',
84: 'type' => 'action',
85: 'getter' => 'getId',
86: 'actions' => array(
87: array(
88: 'caption' => Mage::helper('catalog')->__('Show Details'),
89: 'url' => array(
90: 'base'=>'*/*/tagDetail'
91: ),
92: 'field' => 'id'
93: )
94: ),
95: 'is_system' => true,
96: 'filter' => false,
97: 'sortable' => false,
98: 'index' => 'stores',
99: ));
100: $this->setFilterVisibility(false);
101:
102: $this->addExportType('*/*/exportPopularCsv', Mage::helper('reports')->__('CSV'));
103: $this->addExportType('*/*/exportPopularExcel', Mage::helper('reports')->__('Excel XML'));
104:
105: return parent::_prepareColumns();
106: }
107:
108: public function getRowUrl($row)
109: {
110: return $this->getUrl('*/*/tagDetail', array('id'=>$row->getTagId()));
111: }
112:
113: }
114: