Getting popular searches at Magento

I want to show the top 10 searches in my Magento store. Magento already stores searches made in the store in the section "Admin"> "Catalog"> "Search conditions", so this is just a matter of getting it in my opinion. Does anyone know which helper or function I can get to get this list?

+4
source share
2 answers

You have the setPopularQueryFilter method in the Mage_CatalogSearch_Model_Mysql4_Query_Collection class, after which you only need to set the limit, I think :)

Without trying, it should be something like this:

$searchCollectino=Mage::getModel('catalogsearch/query')->getCollection() ->setPopularQueryFilter() ->setPageSize($limit); 
+8
source

If someone needs a Magento 2 solution:

enter the \Magento\Search\Model\Query class into your constructor, and then retrieve the collection as follows: $collection = $this->query->getSuggestCollection()

This will return a collection of the most popular search terms, sorted by popularity.

0
source

Source: https://habr.com/ru/post/1345236/


All Articles