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_Catalog_Search_Grid extends Mage_Adminhtml_Block_Widget_Grid
36: {
37: 38: 39: 40:
41: public function __construct()
42: {
43: parent::__construct();
44: $this->setId('catalog_search_grid');
45: $this->setDefaultSort('name');
46: $this->setDefaultDir('ASC');
47: $this->setSaveParametersInSession(true);
48: }
49:
50: 51: 52: 53: 54:
55: protected function _prepareCollection()
56: {
57: $collection = Mage::getModel('catalogsearch/query')
58: ->getResourceCollection();
59: $this->setCollection($collection);
60: return parent::_prepareCollection();
61: }
62:
63: 64: 65: 66: 67:
68: protected function _prepareColumns()
69: {
70: 71: 72: 73: 74:
75:
76: $this->addColumn('search_query', array(
77: 'header' => Mage::helper('catalog')->__('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('catalog')->__('Results'),
93: 'index' => 'num_results',
94: 'type' => 'number'
95: ));
96:
97: $this->addColumn('popularity', array(
98: 'header' => Mage::helper('catalog')->__('Number of Uses'),
99: 'index' => 'popularity',
100: 'type' => 'number'
101: ));
102:
103: $this->addColumn('synonym_for', array(
104: 'header' => Mage::helper('catalog')->__('Synonym For'),
105: 'align' => 'left',
106: 'index' => 'synonym_for',
107: 'width' => '160px'
108: ));
109:
110: $this->addColumn('redirect', array(
111: 'header' => Mage::helper('catalog')->__('Redirect'),
112: 'align' => 'left',
113: 'index' => 'redirect',
114: 'width' => '200px'
115: ));
116:
117: $this->addColumn('display_in_terms', array(
118: 'header'=>Mage::helper('catalog')->__('Display in Suggested Terms'),
119: 'sortable'=>true,
120: 'index'=>'display_in_terms',
121: 'type' => 'options',
122: 'width' => '100px',
123: 'options' => array(
124: '1' => Mage::helper('catalog')->__('Yes'),
125: '0' => Mage::helper('catalog')->__('No'),
126: ),
127: 'align' => 'left',
128: ));
129: $this->addColumn('action',
130: array(
131: 'header' => Mage::helper('catalog')->__('Action'),
132: 'width' => '100px',
133: 'type' => 'action',
134: 'getter' => 'getId',
135: 'actions' => array(array(
136: 'caption' => Mage::helper('catalog')->__('Edit'),
137: 'url' => array(
138: 'base'=>'*/*/edit'
139: ),
140: 'field' => 'id'
141: )),
142: 'filter' => false,
143: 'sortable' => false,
144: 'index' => 'catalog',
145: ));
146: return parent::_prepareColumns();
147: }
148:
149: 150: 151: 152: 153:
154: protected function _prepareMassaction()
155: {
156: $this->setMassactionIdField('query_id');
157: $this->getMassactionBlock()->setFormFieldName('search');
158:
159: $this->getMassactionBlock()->addItem('delete', array(
160: 'label' => Mage::helper('catalog')->__('Delete'),
161: 'url' => $this->getUrl('*/*/massDelete'),
162: 'confirm' => Mage::helper('catalog')->__('Are you sure?')
163: ));
164:
165: return parent::_prepareMassaction();
166: }
167:
168: 169: 170: 171: 172:
173: public function getRowUrl($row)
174: {
175: return $this->getUrl('*/*/edit', array('id' => $row->getId()));
176: }
177:
178: }
179: