1: <?php
2: /**
3: * Magento
4: *
5: * NOTICE OF LICENSE
6: *
7: * This source file is subject to the Open Software License (OSL 3.0)
8: * that is bundled with this package in the file LICENSE.txt.
9: * It is also available through the world-wide-web at this URL:
10: * http://opensource.org/licenses/osl-3.0.php
11: * If you did not receive a copy of the license and are unable to
12: * obtain it through the world-wide-web, please send an email
13: * to license@magentocommerce.com so we can send you a copy immediately.
14: *
15: * DISCLAIMER
16: *
17: * Do not edit or add to this file if you wish to upgrade Magento to newer
18: * versions in the future. If you wish to customize Magento for your
19: * needs please refer to http://www.magentocommerce.com for more information.
20: *
21: * @category Mage
22: * @package Mage_Adminhtml
23: * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24: * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25: */
26:
27: /**
28: * Adminhtml most viewed products report grid block
29: *
30: * @category Mage
31: * @package Mage_Adminhtml
32: * @author Magento Core Team <core@magentocommerce.com>
33: */
34: class Mage_Adminhtml_Block_Report_Product_Viewed_Grid extends Mage_Adminhtml_Block_Report_Grid_Abstract
35: {
36: /**
37: * Column for grid to be grouped by
38: *
39: * @var string
40: */
41: protected $_columnGroupBy = 'period';
42:
43: /**
44: * Grid resource collection name
45: *
46: * @var string
47: */
48: protected $_resourceCollectionName = 'reports/report_product_viewed_collection';
49:
50: /**
51: * Init grid parameters
52: */
53: public function __construct()
54: {
55: parent::__construct();
56: $this->setCountTotals(true);
57: }
58:
59: /**
60: * Custom columns preparation
61: *
62: * @return Mage_Adminhtml_Block_Widget_Grid
63: */
64: protected function _prepareColumns()
65: {
66: $this->addColumn('period', array(
67: 'header' => Mage::helper('adminhtml')->__('Period'),
68: 'index' => 'period',
69: 'width' => 100,
70: 'sortable' => false,
71: 'period_type' => $this->getPeriodType(),
72: 'renderer' => 'adminhtml/report_sales_grid_column_renderer_date',
73: 'totals_label' => Mage::helper('adminhtml')->__('Total'),
74: 'html_decorators' => array('nobr'),
75: ));
76:
77: $this->addColumn('product_name', array(
78: 'header' => Mage::helper('adminhtml')->__('Product Name'),
79: 'index' => 'product_name',
80: 'type' => 'string',
81: 'sortable' => false
82: ));
83:
84: if ($this->getFilterData()->getStoreIds()) {
85: $this->setStoreIds(explode(',', $this->getFilterData()->getStoreIds()));
86: }
87: $currencyCode = $this->getCurrentCurrencyCode();
88:
89: $this->addColumn('product_price', array(
90: 'header' => Mage::helper('adminhtml')->__('Price'),
91: 'type' => 'currency',
92: 'currency_code' => $currencyCode,
93: 'index' => 'product_price',
94: 'sortable' => false,
95: 'rate' => $this->getRate($currencyCode),
96: ));
97:
98: $this->addColumn('views_num', array(
99: 'header' => Mage::helper('adminhtml')->__('Number of Views'),
100: 'index' => 'views_num',
101: 'type' => 'number',
102: 'total' => 'sum',
103: 'sortable' => false
104: ));
105:
106:
107: $this->addExportType('*/*/exportViewedCsv', Mage::helper('adminhtml')->__('CSV'));
108: $this->addExportType('*/*/exportViewedExcel', Mage::helper('adminhtml')->__('Excel XML'));
109:
110: return parent::_prepareColumns();
111: }
112:
113: /**
114: * Don't use orders in collection
115: *
116: * @param Mage_Reports_Model_Resource_Report_Collection_Abstract $collection
117: * @param Varien_Object $filterData
118: * @return Mage_Adminhtml_Block_Report_Grid_Abstract
119: */
120: protected function _addOrderStatusFilter($collection, $filterData)
121: {
122: return $this;
123: }
124: }
125: