00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 class Mage_Adminhtml_Block_Dashboard_Searches_Last extends Mage_Adminhtml_Block_Dashboard_Grid
00036 {
00037 protected $_collection;
00038
00039 public function __construct()
00040 {
00041 parent::__construct();
00042 $this->setId('lastSearchGrid');
00043 }
00044
00045 protected function _prepareCollection()
00046 {
00047 $this->_collection = Mage::getModel('catalogsearch/query')
00048 ->getResourceCollection();
00049 $this->_collection->setRecentQueryFilter();
00050
00051 if ($this->getRequest()->getParam('store')) {
00052 $this->_collection->addFieldToFilter('store_id', $this->getRequest()->getParam('store'));
00053 } else if ($this->getRequest()->getParam('website')){
00054 $storeIds = Mage::app()->getWebsite($this->getRequest()->getParam('website'))->getStoreIds();
00055 $this->_collection->addFieldToFilter('store_id', array('in' => $storeIds));
00056 } else if ($this->getRequest()->getParam('group')){
00057 $storeIds = Mage::app()->getGroup($this->getRequest()->getParam('group'))->getStoreIds();
00058 $this->_collection->addFieldToFilter('store_id', array('in' => $storeIds));
00059 }
00060
00061 $this->setCollection($this->_collection);
00062
00063 return parent::_prepareCollection();
00064 }
00065
00066 protected function _prepareColumns()
00067 {
00068 $this->addColumn('search_query', array(
00069 'header' => $this->__('Search Term'),
00070 'sortable' => false,
00071 'index' => 'query_text',
00072 'renderer' => 'adminhtml/dashboard_searches_renderer_searchquery',
00073 ));
00074
00075 $this->addColumn('num_results', array(
00076 'header' => $this->__('Results'),
00077 'sortable' => false,
00078 'index' => 'num_results',
00079 'type' => 'number'
00080 ));
00081
00082 $this->addColumn('popularity', array(
00083 'header' => $this->__('Number of Uses'),
00084 'sortable' => false,
00085 'index' => 'popularity',
00086 'type' => 'number'
00087 ));
00088
00089 $this->setFilterVisibility(false);
00090 $this->setPagerVisibility(false);
00091
00092 return parent::_prepareColumns();
00093 }
00094
00095 public function getRowUrl($row)
00096 {
00097 return $this->getUrl('*/catalog_search/edit', array('id'=>$row->getId()));
00098 }
00099 }