Jump to content

[EXAMPLE] adding a tab to AdminProducts.php via a module


codegrunt
 Share

Recommended Posts

Howdy. I finally managed to get this to work so I thought I would give a quick and dirty how to for anyone in a similar situation. If this is already a FAQ (I did look first) my apologies for the distraction.

I am working on a module at the moment that needs to be associated with the product editor. Unfortunately, Prestashop is extremely stingy with built hooks for the product editing page. In fact, there is no hook that allows control of the product editor directly - there are hooks for product update and product delete but nothing that can add a new tab (why I do not know).

What we do have access to however is the hook "backOfficeFooter". I am not sure if this is foolproof yet but the following appears to work for adding a new tab when on the product editor page:

public function hookbackOfficeFooter()
{
   if(
       Tools::getValue('tab')=='AdminCatalog'
       && Tools::getValue('updateproduct')!==false
   )
   {

       echo '
       [removed]
       $(document).ready(function() {
           $("div#tabPane1").append(\'8. '.$this->l('My Tab').'
Some test content goes here.\');
           toload[8] = false;
           }
           );

       [removed]

       ';
   }
}



I am haven't fully unrolled the toload ajax functionality yet but at least it is possible to add a new tab without mangling the core system files.

Cheers

Share this post


Link to post
Share on other sites

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
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More