Skip to content

Commit 2aaba35

Browse files
committed
Merge remote-tracking branch 'magento-tango/MC-21808' into MPI-PR-2019-10-18
2 parents ebe03c2 + 3811aea commit 2aaba35

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

app/code/Magento/Search/Model/ResourceModel/Query/Collection.php

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ public function setQueryFilter($query)
130130
*/
131131
public function setPopularQueryFilter($storeIds = null)
132132
{
133-
134133
$this->getSelect()->reset(
135134
\Magento\Framework\DB\Select::FROM
136135
)->reset(
@@ -140,13 +139,10 @@ public function setPopularQueryFilter($storeIds = null)
140139
)->from(
141140
['main_table' => $this->getTable('search_query')]
142141
);
143-
if ($storeIds) {
144-
$this->addStoreFilter($storeIds);
145-
$this->getSelect()->where('num_results > 0');
146-
} elseif (null === $storeIds) {
147-
$this->addStoreFilter($this->_storeManager->getStore()->getId());
148-
$this->getSelect()->where('num_results > 0');
149-
}
142+
143+
$storeIds = $storeIds ?: $this->_storeManager->getStore()->getId();
144+
$this->addStoreFilter($storeIds);
145+
$this->getSelect()->where('num_results > 0');
150146

151147
$this->getSelect()->order(['popularity desc']);
152148

@@ -172,10 +168,9 @@ public function setRecentQueryFilter()
172168
*/
173169
public function addStoreFilter($storeIds)
174170
{
175-
if (!is_array($storeIds)) {
176-
$storeIds = [$storeIds];
177-
}
178-
$this->getSelect()->where('main_table.store_id IN (?)', $storeIds);
171+
$condition = is_array($storeIds) ? 'main_table.store_id IN (?)' : 'main_table.store_id = ?';
172+
$this->getSelect()->where($condition, $storeIds);
173+
179174
return $this;
180175
}
181176
}

app/code/Magento/Search/etc/db_schema.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@
4646
<index referenceId="SEARCH_QUERY_IS_PROCESSED" indexType="btree">
4747
<column name="is_processed"/>
4848
</index>
49+
<index referenceId="SEARCH_QUERY_STORE_ID_POPULARITY" indexType="btree">
50+
<column name="store_id"/>
51+
<column name="popularity"/>
52+
</index>
4953
</table>
5054
<table name="search_synonyms" resource="default" engine="innodb" comment="table storing various synonyms groups">
5155
<column xsi:type="bigint" name="group_id" padding="20" unsigned="true" nullable="false" identity="true"

app/code/Magento/Search/etc/db_schema_whitelist.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"SEARCH_QUERY_QUERY_TEXT_STORE_ID_POPULARITY": true,
1818
"SEARCH_QUERY_STORE_ID": true,
1919
"SEARCH_QUERY_IS_PROCESSED": true,
20-
"SEARCH_QUERY_SYNONYM_FOR": true
20+
"SEARCH_QUERY_SYNONYM_FOR": true,
21+
"SEARCH_QUERY_STORE_ID_POPULARITY": true
2122
},
2223
"constraint": {
2324
"PRIMARY": true,
@@ -43,4 +44,4 @@
4344
"SEARCH_SYNONYMS_WEBSITE_ID_STORE_WEBSITE_WEBSITE_ID": true
4445
}
4546
}
46-
}
47+
}

0 commit comments

Comments
 (0)