Jump to content

Adding an admin menu item (tab) in Prestashop 1.7.6.8


Recommended Posts

Just to share the knowledge

I was migrating my module that was made for 1.6 to 1.7 and ran into the issue that the menu item wasn't added.

I checked my code against what I read in this post but that didn't help.
Also I read what was written in the official, not up to date, developer documentation on Confluence.

Long story short: At least in 1.7.6.8 you MUST choose a parent page.
Without it, your menu will simply not be shown.

Here's the code that will work:

$tab_id = Tab::getIdFromClassName('AdminYourModulesClassName');
$languages = Language::getLanguages(false);

if ($tab_id == false)
{
    $tab = new Tab();
    $tab->class_name = 'AdminYourModulesClassName';
    $tab->position = 99;
    $tab->id_parent = (int)Tab::getIdFromClassName('DEFAULT'); // This value isn't listed in the developer documenation but I found it in the database. Alternatively it may be wise to use another value as DEFAULT may not exist in earlier 1.7 versions (I have not checked this!)
    $tab->module = 'The name of your module';
    foreach ($languages as $language) {
        $tab->name[$language['id_lang']] = "Lovely Module";
    }
    $tab->add();
}

The above cost me almost 1,5 hour to solve, but I hope it helps you.

 

Good luck!
 

 

  • Thanks 2
Link to comment
Share on other sites

  • 11 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...