- Модуль: sale
- Путь к файлу: ~/bitrix/modules/sale/lib/location/search/word.php
- Класс: BitrixSaleLocationSearchWordTable
- Вызов: WordTable::initializeData
public function initializeData()
{
$res = LocationNameLocationTable::getList(array(
'select' => array(
'NAME',
'LOCATION_ID'
),
'filter' => static::getFilterForInitData(array(
'TYPES' => $this->procData['ALLOWED_TYPES'],
'LANGS' => $this->procData['ALLOWED_LANGS']
)),
'order' => array('LOCATION_ID' => 'asc'), // need to make same location ids stay together
'limit' => static::STEP_SIZE,
'offset' => $this->procData['OFFSET']
));
$cnt = 0;
while($item = $res->fetch())
{
if($item['NAME'] <> '')
{
if($this->procData['CURRENT_LOCATION'] != $item['LOCATION_ID'])
{
$this->procData['CURRENT_LOCATION_WORDS'] = array();
}
$this->procData['CURRENT_LOCATION'] = $item['LOCATION_ID'];
$words = static::parseString($item['NAME']);
foreach($words as $k => &$word)
{
$wordHash = md5($word);
$wordId = false;
if(isset($this->dictionaryIndex[$wordHash])) // word is already added and in a hot index
{
$wordId = $this->dictionaryIndex[$wordHash];
}
else
{
$wordId = static::getIdByWord($word); // check if the word was added previously
}
if($wordId === false)
{
$wordId = $this->dictionaryInserter->insert(array(
'WORD' => $word
));
$this->dictionaryIndex[$wordHash] = $wordId;
}
if($wordId !== false && !isset($this->procData['CURRENT_LOCATION_WORDS'][$wordId]))
{
$this->procData['CURRENT_LOCATION_WORDS'][$wordId] = true;
$this->word2LocationInserter->insert(array(
'LOCATION_ID' => intval($item['LOCATION_ID']),
'WORD_ID' => intval($wordId)
));
}
}
}
$cnt++;
}
$this->procData['OFFSET'] += static::STEP_SIZE;
$this->dictionaryInserter->flush();
$this->word2LocationInserter->flush();
return !$cnt;
}