// Truncate search index table (using DELETE to avoid committing database transactions in tests)
$this->connection->
executeStatement('DELETE FROM `s_search_index`'
);
// Get a list of all tables and columns in this tables that should be processed by search
/**
* Example return:
* tableID | table | where | reference_table | fieldIDs | fields | foreign_key
* 1 | s_articles | NULL | NULL | 3,4 | name, keywords | NULL
* 2 | s_categories | NULL | s_articles_categories | 1,2 | metakeywords, description | categoryID
*/
$tables =
$this->
getSearchTables();
if (!
empty($tables)) { foreach ($tables as $table) { // Set primary key
$table['elementID'
] =
empty($table['foreign_key'
]) &&
$table['table'
] !== 's_articles' ? 'articleID' : 'id';
if ($table['table'
] === 's_articles_attributes'
) { $table['elementID'
] = '(SELECT articleID FROM s_articles_details WHERE id = articledetailsID LIMIT 1)';
} // Build sql query to fetch values from this table