|
9 | 9 | use Magento\Framework\Data\Collection\EntityFactoryInterface; |
10 | 10 | use Magento\Framework\DB\Adapter\AdapterInterface; |
11 | 11 | use Magento\Framework\DB\Helper; |
| 12 | +use Magento\Framework\DB\Select; |
12 | 13 | use Magento\Framework\Event\ManagerInterface; |
13 | 14 | use Magento\Framework\Model\ResourceModel\Db\AbstractDb; |
14 | 15 | use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection; |
@@ -116,21 +117,22 @@ public function getStoreId() |
116 | 117 | */ |
117 | 118 | public function setQueryFilter($query) |
118 | 119 | { |
119 | | - $this->getSelect()->reset( |
120 | | - \Magento\Framework\DB\Select::FROM |
121 | | - )->distinct( |
122 | | - true |
123 | | - )->from( |
124 | | - ['main_table' => $this->getTable('search_query')] |
125 | | - )->where( |
126 | | - 'num_results > 0 AND display_in_terms = 1 AND query_text LIKE ?', |
127 | | - $this->_resourceHelper->addLikeEscape($query, ['position' => 'start']) |
128 | | - )->order( |
129 | | - 'popularity ' . \Magento\Framework\DB\Select::SQL_DESC |
130 | | - ); |
| 120 | + $this->getSelect() |
| 121 | + ->reset(Select::FROM) |
| 122 | + ->distinct(true) |
| 123 | + ->from(['main_table' => $this->getTable('search_query')]) |
| 124 | + ->reset(Select::COLUMNS) |
| 125 | + ->columns(['query_text', 'num_results', 'popularity']) |
| 126 | + ->where( |
| 127 | + 'num_results > 0 AND display_in_terms = 1 AND query_text LIKE ?', |
| 128 | + $this->_resourceHelper->addLikeEscape($query, ['position' => 'start']) |
| 129 | + ) |
| 130 | + ->order('popularity ' . \Magento\Framework\DB\Select::SQL_DESC); |
| 131 | + |
131 | 132 | if ($this->getStoreId()) { |
132 | 133 | $this->getSelect()->where('store_id = ?', (int)$this->getStoreId()); |
133 | 134 | } |
| 135 | + |
134 | 136 | return $this; |
135 | 137 | } |
136 | 138 |
|
|
0 commit comments