Is there a way to get the 5 tops search terms like in the Dashboard as array
without having to query database->table directly sorting them popularity limit 5?
1 Answer
Found a way using Magento\Search\Model\ResourceModel\Query\CollectionFactory
...
$searchCollection = $this->_queryCollectionFactory->create()
->setPopularQueryFilter($this->_storeManager->getStore()->getId())
->setPageSize(5)
->load()
->getItems();
foreach($searchCollection as $k=>$v) {
echo $vv->getQueryText().', ';
}
...