Prestashop : Utiliser la liste des catégories produits dans un module

Si vous souhaitez utiliser la liste des catégories de produits Prestashop dans votre module voici comment procéder.

Prestashop 1.5

$categoryTree = new Helper();
	/**
	 *
	 * @param array $root array with the name and ID of the tree root category, if null the Shop's root category will be used
	 * @param type $selected_cat array of selected categories
	 *					Format
	 *						Array
	 * 					(
	 *							 [0] => 1
	 *						 [1] => 2
	 *					)
	 * 					OR
	 *					Array
	 *					(
	 *						 [1] => Array
	 *							  (
	 *									[id_category] => 1
	 *									[name] => Home page
	 *							  )
	 *					)
	 * @param string $input_name name of input
	 * @param bool $use_radio use radio tree or checkbox tree
	 * @param bool $use_search display a find category search box
	 * @param array $disabled_categories
	 * @param bool $use_in_popup
	 * @param bool $use_shop_context
	 * @return string
	 */
echo $categoryTree->renderCategoryTree(null,array(),'id-category-for-insert');

Prestashop 1.6

$categoryTree = new HelperTreeCategories('categories-tree', $this->l('Check the category to display the link'));
echo $categoryTree->setAttribute()
->setInputName('id-category')
->render();

Par contre ces helpers ne fonctionnent malheureusement qu’en back office.…

Prestashop : Utiliser la liste des catégories produits dans un module Lire la suite »