My question is :
How can I add, by code, a custom menu item for my prestashop module under the orders menu (for example) in the pestashop backoffice ?
You can add a menu item on module install function.
$currentid = Tab::getIdFromClassName('YOUR_ADMINCLASS');
if (!$currentid ) {
$tab = new Tab();
$tab->active = 1;
$tab->class_name = "YOUR_ADMINCLASS";
$tab->name = array();
foreach (Language::getLanguages() as $lang){
$tab->name[$lang['id_lang']] = "DISPLAYNAME";
}
$tab->id_parent = $parentTabid;
$tab->module = $this->name;
$tab->add();
}
To place as submenu or Orders, search for the $parentTabid
:
$sql = "SELECT `id_tab` FROM `"._DB_PREFIX_."tab` WHERE `class_name` LIKE 'AdminParentOrders'";
$parentTabid = Db::getInstance()->getValue($sql);