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_Product_Grid extends Mage_Adminhtml_Block_Widget_Grid
35: {
36:
37: public function __construct()
38: {
39: parent::__construct();
40: $this->setId('productsReportGrid');
41: $this->setDefaultSort('entity_id');
42: $this->setDefaultDir('desc');
43: }
44:
45: protected function _prepareCollection()
46: {
47:
48: $collection = Mage::getResourceModel('reports/product_collection');
49: $collection->getEntity()->setStore(0);
50:
51: $this->setCollection($collection);
52:
53: return parent::_prepareCollection();
54: }
55:
56: protected function _afterLoadCollection()
57: {
58: $totalObj = new Mage_Reports_Model_Totals();
59: $this->setTotals($totalObj->countTotals($this));
60: }
61:
62: protected function _prepareColumns()
63: {
64: $this->addColumn('entity_id', array(
65: 'header' =>Mage::helper('reports')->__('ID'),
66: 'width' =>'50px',
67: 'index' =>'entity_id',
68: 'total' =>'Total'
69: ));
70:
71: $this->addColumn('name', array(
72: 'header' =>Mage::helper('reports')->__('Name'),
73: 'index' =>'name'
74: ));
75:
76: $this->addColumn('viewed', array(
77: 'header' =>Mage::helper('reports')->__('Number Viewed'),
78: 'width' =>'50px',
79: 'align' =>'right',
80: 'index' =>'viewed',
81: 'total' =>'sum'
82: ));
83:
84: $this->addColumn('added', array(
85: 'header' =>Mage::helper('reports')->__('Number Added'),
86: 'width' =>'50px',
87: 'align' =>'right',
88: 'index' =>'added',
89: 'total' =>'sum'
90: ));
91:
92: $this->addColumn('purchased', array(
93: 'header' =>Mage::helper('reports')->__('Number Purchased'),
94: 'width' =>'50px',
95: 'align' =>'right',
96: 'index' =>'purchased',
97: 'total' =>'sum'
98: ));
99:
100: $this->addColumn('fulfilled', array(
101: 'header' =>Mage::helper('reports')->__('Number Fulfilled'),
102: 'width' =>'50px',
103: 'align' =>'right',
104: 'index' =>'fulfilled',
105: 'total' =>'sum'
106: ));
107:
108: $this->addColumn('revenue', array(
109: 'header' =>Mage::helper('reports')->__('Revenue'),
110: 'width' =>'50px',
111: 'align' =>'right',
112: 'index' =>'revenue',
113: 'total' =>'sum'
114: ));
115:
116: $this->setCountTotals(true);
117:
118: $this->addExportType('*/*/exportProductsCsv', Mage::helper('reports')->__('CSV'));
119: $this->addExportType('*/*/exportProductsExcel', Mage::helper('reports')->__('Excel XML'));
120:
121: return parent::_prepareColumns();
122: }
123:
124: }
125:
126: