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_Sales_Bestsellers_Grid extends Mage_Adminhtml_Block_Report_Grid_Abstract
35: {
36: protected $_columnGroupBy = 'period';
37:
38: public function __construct()
39: {
40: parent::__construct();
41: $this->setCountTotals(true);
42: }
43:
44: public function getResourceCollectionName()
45: {
46: return 'sales/report_bestsellers_collection';
47: }
48:
49: protected function _prepareColumns()
50: {
51: $this->addColumn('period', array(
52: 'header' => Mage::helper('sales')->__('Period'),
53: 'index' => 'period',
54: 'width' => 100,
55: 'sortable' => false,
56: 'period_type' => $this->getPeriodType(),
57: 'renderer' => 'adminhtml/report_sales_grid_column_renderer_date',
58: 'totals_label' => Mage::helper('adminhtml')->__('Total'),
59: 'html_decorators' => array('nobr'),
60: ));
61:
62: $this->addColumn('product_name', array(
63: 'header' => Mage::helper('sales')->__('Product Name'),
64: 'index' => 'product_name',
65: 'type' => 'string',
66: 'sortable' => false
67: ));
68:
69: if ($this->getFilterData()->getStoreIds()) {
70: $this->setStoreIds(explode(',', $this->getFilterData()->getStoreIds()));
71: }
72: $currencyCode = $this->getCurrentCurrencyCode();
73:
74: $this->addColumn('product_price', array(
75: 'header' => Mage::helper('sales')->__('Price'),
76: 'type' => 'currency',
77: 'currency_code' => $currencyCode,
78: 'index' => 'product_price',
79: 'sortable' => false,
80: 'rate' => $this->getRate($currencyCode),
81: ));
82:
83: $this->addColumn('qty_ordered', array(
84: 'header' => Mage::helper('sales')->__('Quantity Ordered'),
85: 'index' => 'qty_ordered',
86: 'type' => 'number',
87: 'total' => 'sum',
88: 'sortable' => false
89: ));
90:
91:
92: $this->addExportType('*/*/exportBestsellersCsv', Mage::helper('adminhtml')->__('CSV'));
93: $this->addExportType('*/*/exportBestsellersExcel', Mage::helper('adminhtml')->__('Excel XML'));
94:
95: return parent::_prepareColumns();
96: }
97: }
98: