Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions
SearchTermManager Class Reference

Public Member Functions

 __construct (array $searchTerms, $totalProductsCount)
 
 applySearchTermsToDescription (&$description, $currentProductIndex)
 

Detailed Description

Class SearchTermManager

Class responsible for applying search terms to description based on search terms description

Definition at line 14 of file SearchTermManager.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( array  $searchTerms,
  $totalProductsCount 
)
Parameters
array$searchTerms
int$totalProductsCount

Definition at line 35 of file SearchTermManager.php.

36  {
37  $this->searchTerms = $searchTerms;
38  $this->totalProductsCount = (int) $totalProductsCount;
39  }

Member Function Documentation

◆ applySearchTermsToDescription()

applySearchTermsToDescription ( $description,
  $currentProductIndex 
)

Apply search terms to product description based on search terms use distribution

Parameters
string$description
int$currentProductIndex
Returns
void

Definition at line 49 of file SearchTermManager.php.

50  {
51  if ($this->searchTermsUseRate === null) {
52  $this->calculateSearchTermsUseRate();
53  }
54 
55  foreach ($this->searchTerms as &$searchTerm) {
56  if ($this->searchTermsUseRate[$searchTerm['term']]['use_rate'] > 0
57  && $currentProductIndex % $this->searchTermsUseRate[$searchTerm['term']]['use_rate'] === 0
58  && $this->searchTermsUseRate[$searchTerm['term']]['used'] < $searchTerm['count']
59  ) {
60  $description .= ' ' . $searchTerm['term'];
61  $this->searchTermsUseRate[$searchTerm['term']]['used'] += 1;
62  }
63  }
64  }

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