ajusting autocomplete ajax_product search
This commit is contained in:
parent
a8045cfefa
commit
2ac3271169
@ -56,7 +56,7 @@ $enabledOnly = Tools::getValue('enabledOnly', false);
|
||||
$excludeVirtuals = (bool)Tools::getValue('excludeVirtuals', false);
|
||||
|
||||
$items = Db::getInstance()->ExecuteS('
|
||||
SELECT p.`id_product`, `reference`, pl.`name`, i.`id_image`
|
||||
SELECT p.`id_product`, `reference`, pl.`name`, pl.`link_rewrite`, i.`id_image`
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.id_product = p.id_product)
|
||||
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1)
|
||||
@ -64,13 +64,14 @@ WHERE (pl.name LIKE \'%'.pSQL($query).'%\' OR p.reference LIKE \'%'.pSQL($query)
|
||||
(!empty($excludeIds) ? ' AND p.id_product NOT IN ('.$excludeIds.') ' : ' ').
|
||||
($enabledOnly ? ' AND p.`active` = 1 ' : ' ').
|
||||
($excludeVirtuals ? 'AND p.id_product NOT IN (SELECT pd.id_product FROM `'._DB_PREFIX_.'product_download` pd WHERE (pd.id_product = p.id_product))' : ''));
|
||||
|
||||
$link = new Link();
|
||||
if ($items)
|
||||
foreach ($items AS $item){
|
||||
$img_path = '';
|
||||
if(isset($item['id_image']) && !empty($item['id_image'])){
|
||||
$image_obj = new Image((int)$item['id_image']);
|
||||
$img_path = (isset($image_obj)?$image_obj->getExistingImgPath():'');
|
||||
// $image_obj = new Image((int)$item['id_image']);
|
||||
// $img_path = (isset($image_obj)?$image_obj->getExistingImgPath():'');
|
||||
$img_path = $link->getImageLink($item['link_rewrite'], (int)$item['id_image'], 'small');
|
||||
}
|
||||
echo trim($item['name']).(!empty($item['reference']) ? ' (ref: '.$item['reference'].')' : '').'|'.(int)($item['id_product']).(!empty($img_path) ?'|'.($img_path):'')."\n";
|
||||
}
|
||||
|
@ -3627,7 +3627,7 @@ class AdminProducts extends AdminTab
|
||||
scroll:false,
|
||||
cacheLength:0,
|
||||
formatItem: function(item) {
|
||||
return \'<img src="'._THEME_PROD_DIR_.'\'+item[2]+\'-small.jpg" /> \'+item[1]+\' - \'+item[0];
|
||||
return \'<img src="\'+item[2]+\'" /> \'+item[1]+\' - \'+item[0];
|
||||
},
|
||||
}).result(addAccessory);
|
||||
$(\'#product_autocomplete_input\').setOptions({
|
||||
|
@ -334,7 +334,7 @@ function addAccessory(event, data, formatted)
|
||||
var $imgAccessories = $('#imgAccessories');
|
||||
|
||||
/* delete product from select + add product line to the div, input_name, input_ids elements */
|
||||
$divAccessories.html($divAccessories.html() + '<img src="/img/p/'+productImg+'-small.jpg" /> ' + productName + ' <span onclick="delAccessory(' + productId + ');" style="cursor: pointer;"><img src="../img/admin/delete.gif" /></span><br />');
|
||||
$divAccessories.html($divAccessories.html() + '<img src="'+productImg+'" /> ' + productName + ' <span onclick="delAccessory(' + productId + ');" style="cursor: pointer;"><img src="../img/admin/delete.gif" /></span><br />');
|
||||
$nameAccessories.val($nameAccessories.val() + productName + '¤');
|
||||
$inputAccessories.val($inputAccessories.val() + productId + '-');
|
||||
$imgAccessories.val($imgAccessories.val() + productImg + ',');
|
||||
|
Loading…
Reference in New Issue
Block a user