45 lines
1.3 KiB
PHP
45 lines
1.3 KiB
PHP
<?php
|
|
|
|
class AdminSearchController extends AdminSearchControllerCore
|
|
{
|
|
public function displayAjaxSearchCron()
|
|
{
|
|
if (!Tools::getValue('id_shop')) {
|
|
Context::getContext()->shop->setContext(Shop::CONTEXT_ALL);
|
|
} else {
|
|
Context::getContext()->shop->setContext(Shop::CONTEXT_SHOP, (int) Tools::getValue('id_shop'));
|
|
}
|
|
|
|
ini_set('max_execution_time', 7200);
|
|
|
|
$full = (bool) Tools::getValue('full');
|
|
$start = microtime(true);
|
|
|
|
$countBefore = (int) Db::getInstance()->getValue(
|
|
'SELECT COUNT(*) FROM `' . _DB_PREFIX_ . 'search_index`'
|
|
);
|
|
|
|
Search::indexation($full);
|
|
|
|
$countAfter = (int) Db::getInstance()->getValue(
|
|
'SELECT COUNT(*) FROM `' . _DB_PREFIX_ . 'search_index`'
|
|
);
|
|
|
|
$elapsed = round(microtime(true) - $start, 2);
|
|
|
|
if (Tools::getValue('redirect')) {
|
|
Tools::redirectAdmin($_SERVER['HTTP_REFERER'] . '&conf=4');
|
|
}
|
|
|
|
header('Content-Type: application/json');
|
|
die(json_encode([
|
|
'success' => true,
|
|
'mode' => $full ? 'full' : 'missing',
|
|
'index_entries_before' => $countBefore,
|
|
'index_entries_after' => $countAfter,
|
|
'entries_added' => $countAfter - $countBefore,
|
|
'elapsed_seconds' => $elapsed,
|
|
]));
|
|
}
|
|
}
|