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:
35: class Mage_Adminhtml_Block_Dashboard_Searches_Top extends Mage_Adminhtml_Block_Dashboard_Grid
36: {
37: protected $_collection;
38:
39: public function __construct()
40: {
41: parent::__construct();
42: $this->setId('topSearchGrid');
43: }
44:
45: protected function _prepareCollection()
46: {
47: if (!Mage::helper('core')->isModuleEnabled('Mage_CatalogSearch')) {
48: return parent::_prepareCollection();
49: }
50: $this->_collection = Mage::getModel('catalogsearch/query')
51: ->getResourceCollection();
52:
53: if ($this->getRequest()->getParam('store')) {
54: $storeIds = $this->getRequest()->getParam('store');
55: } else if ($this->getRequest()->getParam('website')){
56: $storeIds = Mage::app()->getWebsite($this->getRequest()->getParam('website'))->getStoreIds();
57: } else if ($this->getRequest()->getParam('group')){
58: $storeIds = Mage::app()->getGroup($this->getRequest()->getParam('group'))->getStoreIds();
59: } else {
60: $storeIds = '';
61: }
62:
63: $this->_collection
64: ->setPopularQueryFilter($storeIds);
65:
66: $this->setCollection($this->_collection);
67:
68: return parent::_prepareCollection();
69: }
70:
71: protected function _prepareColumns()
72: {
73: $this->addColumn('search_query', array(
74: 'header' => $this->__('Search Term'),
75: 'sortable' => false,
76: 'index' => 'name',
77: 'renderer' => 'adminhtml/dashboard_searches_renderer_searchquery',
78: ));
79:
80: $this->addColumn('num_results', array(
81: 'header' => $this->__('Results'),
82: 'sortable' => false,
83: 'index' => 'num_results',
84: 'type' => 'number'
85: ));
86:
87: $this->addColumn('popularity', array(
88: 'header' => $this->__('Number of Uses'),
89: 'sortable' => false,
90: 'index' => 'popularity',
91: 'type' => 'number'
92: ));
93:
94: $this->setFilterVisibility(false);
95: $this->setPagerVisibility(false);
96:
97: return parent::_prepareColumns();
98: }
99:
100: public function getRowUrl($row)
101: {
102: return $this->getUrl('*/catalog_search/edit', array('id'=>$row->getId()));
103: }
104: }
105: