toutpratique/override/controllers/admin/AdminSearchController.php

41 lines
1.2 KiB
PHP
Raw Normal View History

2015-08-12 14:10:25 +02:00
<?php
class AdminSearchController extends AdminSearchControllerCore {
public function __construct()
{
parent::__construct();
}
public function displayAjaxGetProducts()
{
$res = Db::getInstance()->executeS('
SELECT p.id_product as id, pl.name as content
FROM '._DB_PREFIX_.'product p
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` '.Shop::addSqlRestrictionOnLang('pl').')
WHERE 1
'.( Tools::getValue('q') != '' ? ' AND pl.name LIKE "%'.pSQL(Tools::getValue('q')).'%"' : '' ).'
GROUP BY p.id_product
ORDER BY pl.name ASC
LIMIT 0,40
');
die(json_encode(array('results' => $res)));
}
public function displayAjaxGetRelationPosts()
{
$res = Db::getInstance()->executeS('
SELECT p.id_product as id, pl.name as content
FROM '._DB_PREFIX_.'product p
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` '.Shop::addSqlRestrictionOnLang('pl').')
WHERE 1
'.( Tools::getValue('q') != '' ? ' AND pl.name LIKE "%'.pSQL(Tools::getValue('q')).'%"' : '' ).'
GROUP BY p.id_product
ORDER BY pl.name ASC
LIMIT 0,40
');
die(json_encode(array('results' => $res)));
}
}