Skip to content

Commit 2b48dfe

Browse files
MAGETWO-71447: fix popular search terms not displaying on frontend #10484
2 parents 8bbddb0 + 225a9c1 commit 2b48dfe

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

app/code/Magento/Search/Block/Term.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ protected function _loadTerms()
9494
continue;
9595
}
9696
$term->setRatio(($term->getPopularity() - $this->_minPopularity) / $range);
97-
$temp[$term->getName()] = $term;
98-
$termKeys[] = $term->getName();
97+
$temp[$term->getQueryText()] = $term;
98+
$termKeys[] = $term->getQueryText();
9999
}
100100
natcasesort($termKeys);
101101

@@ -127,7 +127,7 @@ public function getSearchUrl($obj)
127127
* url encoding will be done in Url.php http_build_query
128128
* so no need to explicitly called urlencode for the text
129129
*/
130-
$url->setQueryParam('q', $obj->getName());
130+
$url->setQueryParam('q', $obj->getQueryText());
131131
return $url->getUrl('catalogsearch/result');
132132
}
133133

app/code/Magento/Search/view/frontend/templates/term.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<li class="item">
1414
<a href="<?= /* @escapeNotVerified */ $block->getSearchUrl($_term) ?>"
1515
style="font-size:<?= /* @escapeNotVerified */ $_term->getRatio()*70+75 ?>%;">
16-
<?= $block->escapeHtml($_term->getName()) ?>
16+
<?= $block->escapeHtml($_term->getQueryText()) ?>
1717
</a>
1818
</li>
1919
<?php endforeach; ?>

dev/tests/integration/testsuite/Magento/CatalogSearch/Block/TermTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ protected function setUp()
2424
public function testGetSearchUrl()
2525
{
2626
$query = uniqid();
27-
$obj = new \Magento\Framework\DataObject(['name' => $query]);
27+
$obj = new \Magento\Framework\DataObject(['query_text' => $query]);
2828
$this->assertStringEndsWith("/catalogsearch/result/?q={$query}", $this->_block->getSearchUrl($obj));
2929
}
3030
}

0 commit comments

Comments
 (0)