public static function saveIndex($module, $otherId, array $fields, $language = null)
{
// module exists?
if (!in_array('Search', BackendModel::getModules())) {
return;
}
// no fields?
if (empty($fields)) {
return;
}
// set language
if (!$language) {
$language = BL::getWorkingLanguage();
}
// get db
$db = BackendModel::getContainer()->get('database');
// insert search index
foreach ($fields as $field => $value) {
// reformat value
$value = strip_tags((string) $value);
// update search index
$db->execute('INSERT INTO search_index (module, other_id, language, field, value, active)
VALUES (?, ?, ?, ?, ?, ?)
ON DUPLICATE KEY UPDATE value = ?, active = ?', array((string) $module, (int) $otherId, (string) $language, (string) $field, $value, 'Y', $value, 'Y'));
}
// invalidate the cache for search
self::invalidateCache();
}