Jump to content

[SOLVED] hook displayAdminProductsExtra Not Working in 1.5?


Recommended Posts

Hey Guys,

Ive seen everyone referring to this hook to get an extra 'product tab' on the backend. So I've got a module that installs fine and registers the hook (as well as admin product update/save/delete hooks)

 

and then obviously the displayAdminProductsExtra

public function hookDisplayAdminProductsExtra($params)
{
 $id_product = Tools::getValue('id_product');
//do stuff
 return $this->display(__FILE__, 'views/templates/admin/admin.tpl');
}

 

Module installs fine, go to catalogue->add or edit a product and the tab isnt there.

So I think something is wrong with my code, so I stumble across this: http://blog.belvg.co...prestashop.html

 

So I install that module that apparently works, and bam - still no 'product tab'? Im running a clean install of 1.5.3.1. What am I missing?

Edited by SupaMonkey (see edit history)
Link to comment
Share on other sites

So I've done some digging and apparently /controllers/admin/AdminProductsController.php sorts out those tabs.

At some point, it calls:

 /* Adding tab if modules are hooked */
 $modules_list = Hook::getHookModuleExecList('displayAdminProductsExtra');

 

However, when it comes to the results of this, its returning an empty array, so never gets to the actual adding of the tabs.

 

Looking deeper into /classes/Hook.php to see what getHookModuleExecList does, this is the part that concerns us:

 if ($hook_name)
 {
  $retro_hook_name = Hook::getRetroHookName($hook_name);
  $hook_name = strtolower($hook_name);
  $return = array();
  if (isset($list[$hook_name]))
   $return = $list[$hook_name];
  if (isset($list[$retro_hook_name]))
   $return = array_merge($return, $list[$retro_hook_name]);
$fh = fopen("c:\debug.txt", 'a');
fputs($fh,"return: (". $hook_name .") [".print_r($return, true)."] \r\n");
  if (count($return) > 0)
   return $return;
  return false;
 }

 

ignore the fputs, I used that for debugging. when it spews all that out into debug.txt and we look at the line with the displayadminproducstextra it looks like:

return: (displayadminproductsextra) [Array()]

Instead of looking something like:

return: (displaybackofficeheader) [Array
(
   [0] => Array
    (
	    [id_hook] => 50
	    [module] => minicslider
	    [id_module] => 64
	    [live_edit] => 0
    )
)
]

 

So why isnt it returning the two modules that are attached to that hook?

Checking the database, the hook displayAdminProductsExtra has an id of 103. Doing a select from the hook_module for all rows with id_hook = 103, it returns the two results just fine! (my module, and the belvg sample module) - so what the hell?

Link to comment
Share on other sites

  • 2 weeks later...

Hi Michael,

 

Sorry I juste tested on a 1.5.4.0 and all went ok. Please see your bug track. Please test again on a 1.5.4.0.

 

Please be sure your module is really installed on this hook in database, as this is a dynamic hook, please check the install method of the module.

 

See sql queries in the bug track to clear this out.

 

Best regards

  • Like 1
Link to comment
Share on other sites

×
×
  • Create New...