[-] BO: Don't autocomplete with product name already in the shop on product creation
This commit is contained in:
@@ -4126,14 +4126,18 @@ class AdminProductsControllerCore extends AdminController
|
|||||||
$search = Tools::getValue('q');
|
$search = Tools::getValue('q');
|
||||||
$id_lang = Tools::getValue('id_lang');
|
$id_lang = Tools::getValue('id_lang');
|
||||||
$limit = Tools::getValue('limit');
|
$limit = Tools::getValue('limit');
|
||||||
$result = Db::getInstance()->executeS('
|
if (Context::getContext()->shop->getContext() != Shop::CONTEXT_SHOP)
|
||||||
SELECT DISTINCT pl.`name`, p.`id_product`, pl.`id_shop`
|
$result = false;
|
||||||
FROM `'._DB_PREFIX_.'product` p
|
else
|
||||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl
|
$result = Db::getInstance()->executeS('
|
||||||
ON (pl.`id_product` = p.`id_product` AND pl.`id_lang` = '.(int)$id_lang.')
|
SELECT DISTINCT pl.`name`, p.`id_product`, pl.`id_shop`
|
||||||
WHERE pl.`name` LIKE "%'.pSQL($search).'%"
|
FROM `'._DB_PREFIX_.'product` p
|
||||||
GROUP BY pl.`id_product`
|
LEFT JOIN `'._DB_PREFIX_.'product_shop` ps ON (ps.id_product = p.id_product AND ps.id_shop ='.(int)Context::getContext()->shop->id.')
|
||||||
LIMIT '.(int)$limit);
|
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl
|
||||||
|
ON (pl.`id_product` = p.`id_product` AND pl.`id_lang` = '.(int)$id_lang.')
|
||||||
|
WHERE pl.`name` LIKE "%'.pSQL($search).'%" AND ps.id_product IS NULL
|
||||||
|
GROUP BY pl.`id_product`
|
||||||
|
LIMIT '.(int)$limit);
|
||||||
die(Tools::jsonEncode($result));
|
die(Tools::jsonEncode($result));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user