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_Review_Product_Grid extends Mage_Adminhtml_Block_Widget_Grid
35: {
36:
37: public function __construct()
38: {
39: parent::__construct();
40: $this->setId('gridProducts');
41: $this->setDefaultSort('review_cnt');
42: $this->setDefaultDir('desc');
43: }
44:
45: protected function _prepareCollection()
46: {
47: $collection = Mage::getResourceModel('reports/review_product_collection')
48: ->joinReview();
49:
50: $this->setCollection($collection);
51:
52: return parent::_prepareCollection();
53: }
54:
55: protected function _prepareColumns()
56: {
57:
58: $this->addColumn('entity_id', array(
59: 'header' =>Mage::helper('reports')->__('ID'),
60: 'width' =>'50px',
61: 'index' =>'entity_id'
62: ));
63:
64: $this->addColumn('name', array(
65: 'header' => Mage::helper('reports')->__('Product Name'),
66: 'index' => 'name'
67: ));
68:
69: $this->addColumn('review_cnt', array(
70: 'header' =>Mage::helper('reports')->__('Number of Reviews'),
71: 'width' =>'50px',
72: 'align' =>'right',
73: 'index' =>'review_cnt'
74: ));
75:
76: $this->addColumn('avg_rating', array(
77: 'header' =>Mage::helper('reports')->__('Avg. Rating'),
78: 'width' =>'50px',
79: 'align' =>'right',
80: 'index' =>'avg_rating'
81: ));
82:
83: $this->addColumn('avg_rating_approved', array(
84: 'header' =>Mage::helper('reports')->__('Avg. Approved Rating'),
85: 'width' =>'50px',
86: 'align' =>'right',
87: 'index' =>'avg_rating_approved'
88: ));
89:
90: $this->addColumn('last_created', array(
91: 'header' =>Mage::helper('reports')->__('Last Review'),
92: 'width' =>'150px',
93: 'index' =>'last_created',
94: 'type' =>'datetime'
95: ));
96:
97: $this->addColumn('action', array(
98: 'header' => Mage::helper('reports')->__('Action'),
99: 'width' => '100px',
100: 'align' => 'center',
101: 'filter' => false,
102: 'sortable' => false,
103: 'renderer' => 'adminhtml/report_grid_column_renderer_product',
104: 'is_system' => true
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('*/catalog_product_review/', array('productId' => $row->getId()));
118: }
119: }
120: