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_Last extends Mage_Adminhtml_Block_Dashboard_Grid
36: {
37: protected $_collection;
38:
39: public function __construct()
40: {
41: parent::__construct();
42: $this->setId('lastSearchGrid');
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: $this->_collection->setRecentQueryFilter();
53:
54: if ($this->getRequest()->getParam('store')) {
55: $this->_collection->addFieldToFilter('store_id', $this->getRequest()->getParam('store'));
56: } else if ($this->getRequest()->getParam('website')){
57: $storeIds = Mage::app()->getWebsite($this->getRequest()->getParam('website'))->getStoreIds();
58: $this->_collection->addFieldToFilter('store_id', array('in' => $storeIds));
59: } else if ($this->getRequest()->getParam('group')){
60: $storeIds = Mage::app()->getGroup($this->getRequest()->getParam('group'))->getStoreIds();
61: $this->_collection->addFieldToFilter('store_id', array('in' => $storeIds));
62: }
63:
64: $this->setCollection($this->_collection);
65:
66: return parent::_prepareCollection();
67: }
68:
69: protected function _prepareColumns()
70: {
71: $this->addColumn('search_query', array(
72: 'header' => $this->__('Search Term'),
73: 'sortable' => false,
74: 'index' => 'query_text',
75: 'renderer' => 'adminhtml/dashboard_searches_renderer_searchquery',
76: ));
77:
78: $this->addColumn('num_results', array(
79: 'header' => $this->__('Results'),
80: 'sortable' => false,
81: 'index' => 'num_results',
82: 'type' => 'number'
83: ));
84:
85: $this->addColumn('popularity', array(
86: 'header' => $this->__('Number of Uses'),
87: 'sortable' => false,
88: 'index' => 'popularity',
89: 'type' => 'number'
90: ));
91:
92: $this->setFilterVisibility(false);
93: $this->setPagerVisibility(false);
94:
95: return parent::_prepareColumns();
96: }
97:
98: public function getRowUrl($row)
99: {
100: return $this->getUrl('*/catalog_search/edit', array('id'=>$row->getId()));
101: }
102: }
103: