Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields
PopularSearchTerms Class Reference

Public Member Functions

 __construct (\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Search\Model\ResourceModel\Query\Collection $queryCollection)
 
 isCacheable (string $term, int $storeId)
 

Data Fields

const XML_PATH_MAX_COUNT_CACHEABLE_SEARCH_TERMS = 'catalog/search/max_count_cacheable_search_terms'
 

Detailed Description

Popular search terms

Definition at line 12 of file PopularSearchTerms.php.

Constructor & Destructor Documentation

◆ __construct()

Parameters
\Magento\Framework\App\Config\ScopeConfigInterface$scopeConfig

Definition at line 34 of file PopularSearchTerms.php.

37  {
38  $this->scopeConfig = $scopeConfig;
39  $this->queryCollection = $queryCollection;
40  }

Member Function Documentation

◆ isCacheable()

isCacheable ( string  $term,
int  $storeId 
)

Check if is cacheable search term

Parameters
string$term
int$storeId
Returns
bool

Definition at line 49 of file PopularSearchTerms.php.

50  {
51  $terms = $this->queryCollection
52  ->setPopularQueryFilter($storeId)
53  ->setPageSize($this->getMaxCountCacheableSearchTerms($storeId))
54  ->load()
55  ->getColumnValues('query_text');
56 
57  return in_array($term, $terms);
58  }

Field Documentation

◆ XML_PATH_MAX_COUNT_CACHEABLE_SEARCH_TERMS

const XML_PATH_MAX_COUNT_CACHEABLE_SEARCH_TERMS = 'catalog/search/max_count_cacheable_search_terms'

Definition at line 14 of file PopularSearchTerms.php.


The documentation for this class was generated from the following file: