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 search 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_Search_Grid extends Mage_Adminhtml_Block_Widget_Grid
35: {
36: /**
37: * Initialize Grid Properties
38: *
39: */
40: public function __construct()
41: {
42: parent::__construct();
43: $this->setId('searchReportGrid');
44: $this->setDefaultSort('query_id');
45: $this->setDefaultDir('desc');
46: }
47:
48: /**
49: * Prepare Search Report collection for grid
50: *
51: * @return Mage_Adminhtml_Block_Report_Search_Grid
52: */
53: protected function _prepareCollection()
54: {
55: $collection = Mage::getResourceModel('catalogsearch/query_collection');
56: $this->setCollection($collection);
57:
58: return parent::_prepareCollection();
59: }
60:
61: /**
62: * Prepare Grid columns
63: *
64: * @return Mage_Adminhtml_Block_Report_Search_Grid
65: */
66: protected function _prepareColumns()
67: {
68: $this->addColumn('query_id', array(
69: 'header' =>Mage::helper('reports')->__('ID'),
70: 'width' =>'50px',
71: 'filter' =>false,
72: 'index' =>'query_id',
73: 'type' =>'number'
74: ));
75:
76: $this->addColumn('query_text', array(
77: 'header' =>Mage::helper('reports')->__('Search Query'),
78: 'index' =>'query_text'
79: ));
80:
81: if (!Mage::app()->isSingleStoreMode()) {
82: $this->addColumn('store_id', array(
83: 'header' => Mage::helper('catalog')->__('Store'),
84: 'index' => 'store_id',
85: 'type' => 'store',
86: 'store_view' => true,
87: 'sortable' => false
88: ));
89: }
90:
91: $this->addColumn('num_results', array(
92: 'header' =>Mage::helper('reports')->__('Results'),
93: 'width' =>'50px',
94: 'align' =>'right',
95: 'type' =>'number',
96: 'index' =>'num_results'
97: ));
98:
99: $this->addColumn('popularity', array(
100: 'header' =>Mage::helper('reports')->__('Hits'),
101: 'width' =>'50px',
102: 'align' =>'right',
103: 'type' =>'number',
104: 'index' =>'popularity'
105: ));
106:
107: $this->addExportType('*/*/exportSearchCsv', Mage::helper('reports')->__('CSV'));
108: $this->addExportType('*/*/exportSearchExcel', Mage::helper('reports')->__('Excel XML'));
109:
110: return parent::_prepareColumns();
111: }
112:
113: /**
114: * Retrieve Row Click callback URL
115: *
116: * @return string
117: */
118: public function getRowUrl($row)
119: {
120: return $this->getUrl('*/catalog_search/edit', array('id' => $row->getId()));
121: }
122: }
123:
124: