Jump to content

BackOffice - product page : only display accessories of active products


Recommended Posts

Hello,

 

on the product page on the accessories part, when you start typing a name you've got all the products corresponding that are displayed.

However it makes more sense if you only display the list of ACTIVE products... I think

 

This is how to process :

 

 

File admin/ajax_products_list.php

add the following parameter : (line 46 for instance)

$onlyActive = Tools::getValue('onlyActive', false);

 

et dans modifier le requête pour qu'il n'y ait plus que les produits actifs si ce paramètre est renseigné :

modifiy the query so as to take into account this parameter and therefore restrict to active products

$items = Db::getInstance()->ExecuteS('
SELECT p.`id_product`, `reference`, pl.name
FROM `'._DB_PREFIX_.'product` p
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.id_product = p.id_product)
WHERE (pl.name LIKE \'%'.pSQL($query).'%\' OR p.reference LIKE \'%'.pSQL($query).'%\') AND pl.id_lang = '.(int)($cookie->id_lang).
(!empty($excludeIds) ? ' AND p.id_product NOT IN ('.$excludeIds.') ' : ' ').
(!empty($onlyActive) ? ' 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))' : ''));

 

Dans le fichier admin/tab/AdminProducts.php add the parameter active=1 into the javascript call to autocomplete :

$(\'#product_autocomplete_input\').setOptions({
	  extraParams: {excludeIds : getAccessorieIds(), onlyActive: 1}
	 });

 

That's it !

 

Ciao

Link to comment
Share on other sites

  • 1 year later...

Great post! I wish i could try it, but i can't get the product to autocomplete, i.e. i begin typing product names, nothing shows. I just started a post just now, (http://www.prestasho...ccessories-etc/), i'm still trying to find information though and came across this. Do you know why this is happening?

Thanks!

Edited by Cari (see edit history)
Link to comment
Share on other sites

×
×
  • Create New...