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_Downloads_Grid extends Mage_Adminhtml_Block_Widget_Grid
35: {
36: public function __construct()
37: {
38: parent::__construct();
39: $this->setId('downloadsGrid');
40: $this->setUseAjax(false);
41: }
42:
43: protected function _prepareCollection()
44: {
45: if ($this->getRequest()->getParam('website')) {
46: $storeIds = Mage::app()->getWebsite($this->getRequest()->getParam('website'))->getStoreIds();
47: $storeId = array_pop($storeIds);
48: } else if ($this->getRequest()->getParam('group')) {
49: $storeIds = Mage::app()->getGroup($this->getRequest()->getParam('group'))->getStoreIds();
50: $storeId = array_pop($storeIds);
51: } else if ($this->getRequest()->getParam('store')) {
52: $storeId = (int)$this->getRequest()->getParam('store');
53: } else {
54: $storeId = '';
55: }
56:
57: $collection = Mage::getResourceModel('reports/product_downloads_collection')
58: ->addAttributeToSelect('*')
59: ->setStoreId($storeId)
60: ->addAttributeToFilter('type_id', array(Mage_Downloadable_Model_Product_Type::TYPE_DOWNLOADABLE))
61: ->addSummary();
62:
63: if( $storeId ) {
64: $collection->addStoreFilter($storeId);
65: }
66:
67: $this->setCollection($collection);
68: return parent::_prepareCollection();
69: }
70:
71: protected function _prepareColumns()
72: {
73: $this->addColumn('name', array(
74: 'header' => Mage::helper('reports')->__('Product Name'),
75: 'index' => 'name'
76: ));
77:
78: $this->addColumn('link_title', array(
79: 'header' => Mage::helper('reports')->__('Link'),
80: 'index' => 'link_title'
81: ));
82:
83: $this->addColumn('sku', array(
84: 'header' =>Mage::helper('reports')->__('Product SKU'),
85: 'index' =>'sku'
86: ));
87:
88: $this->addColumn('purchases', array(
89: 'header' => Mage::helper('reports')->__('Purchases'),
90: 'width' => '215px',
91: 'align' => 'right',
92: 'filter' => false,
93: 'index' => 'purchases',
94: 'type' => 'number',
95: 'renderer' => 'adminhtml/report_product_downloads_renderer_purchases',
96: ));
97:
98: $this->addColumn('downloads', array(
99: 'header' => Mage::helper('reports')->__('Downloads'),
100: 'width' => '215px',
101: 'align' => 'right',
102: 'filter' => false,
103: 'index' => 'downloads',
104: 'type' => 'number'
105: ));
106:
107: $this->addExportType('*/*/exportDownloadsCsv', Mage::helper('reports')->__('CSV'));
108: $this->addExportType('*/*/exportDownloadsExcel', Mage::helper('reports')->__('Excel XML'));
109:
110: return parent::_prepareColumns();
111: }
112: }
113: