Search code examples
prestashop

how to show my admin tab in prestashop 1.7?


i succeeded to show my admin tab in ps 1.6 bu it does not appear in 1.7, here is my code :

  public function installTab()  {
    $tab = new Tab();
    $tab->id_parent = 0;
    //$tab->id_parent = (int)Tab::getIdFromClassName('AdminCatalog');
    $tab->name = array();
    foreach (Language::getLanguages(true) as $lang) {
        $tab->name[$lang['id_lang']] = 'Scan des codes barre';
      }
    $tab->class_name = 'AdminBarCodeGenerator';
    $tab->module = $this->name;
    $tab->active = 1;
    return $tab->add();

}

and my controller's methods:

 public function __construct(){
    $this->bootstrap = true;
    $this->display='';
    $this->context = Context::getContext();
    return parent::__construct();

}

   public function renderList()

{

$scan_form=$this->renderForm2();
$this->context->smarty->assign('scan_form',$scan_form);
return $this->context->smarty->fetch(_PS_MODULE_DIR_.'barcode/views/templates/admin/tabs/scan.tpl');

}

is there a specific way to handle it in ps 1.7 please?


Solution

  • I think problem might be in setting parent id to 0. Try:

    $tab->id_parent = (int)Tab::getIdFromClassName('DEFAULT');
    

    Also your class name should start with Admin