2025-06-16 18:28:08 +05:00

21 lines
934 B
PHP
Executable File

<?php
ini_set('display_errors', 0);
$smarty->caching = true;
$smarty->cache_lifetime = 3600;
//Входящие данные
//Текст запроса
$txt = $_SESSION['find'];
$limit = $_POST['limit'];
$page = intval(@$_POST['page']);
$page = (empty($page)) ? 1 : $page;
$start = ($page != 1) ? $page * $limit - $limit : 0;
if (class_exists('DBmysql')) {
$list = \DBmysql::getAll("SELECT `id`, `title`, `cena`, `artikul`, `code` FROM `tovar` WHERE `status`=1 AND (`title` LIKE '%" . $txt . "%' OR `artikul` LIKE '%" . $txt . "%' OR `code` ='" . $txt . "' OR `json` LIKE '%" . $txt . "%' ) AND `site`=? LIMIT $start, $limit", $_SERVER['SERVER_NAME']);
$count = count($list);
for ($i = 0; $i < $count; $i++) {
$list[$i]['artikul']=\core::getFirstImg($list[$i]['id'], 'tovar');
$list[$i]['artikul'] = ($list[$i]['artikul']) ? $list[$i]['artikul'] : $list[$i]['code'];
}
}
$smarty->assign('list', $list);
?>