SupaMonkey Posted March 19, 2013 Share Posted March 19, 2013 (edited) 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 April 2, 2013 by SupaMonkey (see edit history) Link to comment Share on other sites More sharing options...
SupaMonkey Posted March 19, 2013 Author Share Posted March 19, 2013 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 More sharing options...
SupaMonkey Posted March 20, 2013 Author Share Posted March 20, 2013 Im at my wits end now and Im certain this is a bug. If it was just my module, I would of tackled on - but the fact that a widely used 'tutorial module' for this specific operation isnt functioning - it has to be a bug. Opened a bug report: http://forge.prestashop.com/browse/PSCFV-8362 Link to comment Share on other sites More sharing options...
Gregory Roussac Posted April 2, 2013 Share Posted April 2, 2013 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 1 Link to comment Share on other sites More sharing options...
SupaMonkey Posted April 2, 2013 Author Share Posted April 2, 2013 I had left this because I couldnt move forward with it. Am on 1.5.4 now and I cant replicate it either. Not sure if its due to a fresh install or due to 1.5.4 - but its resolved, thanks. Link to comment Share on other sites More sharing options...
Recommended Posts