chazeprasad Posted February 7, 2013 Share Posted February 7, 2013 I would like to add a new tab in Product Admin page like Features Tab, Attributes Tab etc. in PS Version 1.5.3. I found some help for 1.4.5. But I am looking for the same solution for 1.5.x. Thanks in advance prasad Link to comment Share on other sites More sharing options...
El Patron Posted February 7, 2013 Share Posted February 7, 2013 back office--administration-->menus 1 Link to comment Share on other sites More sharing options...
chazeprasad Posted February 7, 2013 Author Share Posted February 7, 2013 thanks for the reply. actually I want a Tab under Catalog > Product > Please give some idea on how to create one Link to comment Share on other sites More sharing options...
El Patron Posted February 7, 2013 Share Posted February 7, 2013 sorry about that, I see now what you want...one can not add sub menus via the method I described above... you will need create a module that hooks to displayAdminProductsExtra even if you could add a tab, you would still need some module or controller to process it.. best of luck! 1 Link to comment Share on other sites More sharing options...
El Patron Posted February 7, 2013 Share Posted February 7, 2013 you can learn more about how to do this by reviewing the developers guide: http://doc.prestashop.com/display/PS15/Creating+a+module+with+both+front-end+and+back-end+controllers 1 Link to comment Share on other sites More sharing options...
chazeprasad Posted February 7, 2013 Author Share Posted February 7, 2013 Thanks alot. Thanks for your time. Thanks alot. Thanks for your time. 1 Link to comment Share on other sites More sharing options...
gr4devel Posted May 15, 2013 Share Posted May 15, 2013 Sorry if I revamp this topic but I'm also interested in extend one of my modules with a backoffice tab. However I can't access the link posted by eTiendas.co. I'm asked to log in but my forum credentials are rejected. Link to comment Share on other sites More sharing options...
vekia Posted May 16, 2013 Share Posted May 16, 2013 displayAdminProductsExtra - this is hook for additional product tab, in your module you have to register this hook in the install function: !$this->registerHook('displayAdminProductsExtra') then you have to create function with this hook: public function hookDisplayAdminProductsExtra($params) { return $this->display(__FILE__, 'tab-body.tpl'); } and that's all 4 Link to comment Share on other sites More sharing options...
gr4devel Posted May 16, 2013 Share Posted May 16, 2013 (edited) Vekia thank you very much for your help! You and your colleagues are always there to help juniors like me and I really appreciate that!!! P.S: sorry for the lateness of my response and again, thank you very much! Edited May 16, 2013 by gr4devel (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted May 16, 2013 Share Posted May 16, 2013 You're welcome my friend :-) If you've got any other questions related to this thread - feel free to continue discussion here Link to comment Share on other sites More sharing options...
daalfu Posted June 12, 2013 Share Posted June 12, 2013 (edited) First of all I want to thank you, as you helped me a lot with this topic. I am trying to implement a button on to run a query on the database when clicking on the button, but I cannot catch the click event. I implemented the following: module.tpl: <TD><input type="submit" name="updatesettings" value="{l s='Update'}" class="button" /></TD> module.php: public function hookDisplayAdminProductsExtra() { global $smarty, $cookie; $product = $this->context->cookie->product; $smarty->assign('name', $this->l('Gifts')); $smarty->assign('Hint', $this->l('The customer will be allowed to pick a product from this category for free.')); $smarty->assign('credits', $this->l('Powered by BlazingArts')); //GET CATEGORIES $sql = 'SELECT '._DB_PREFIX_.'category.id_category, '._DB_PREFIX_.'category_lang.name '; $sql .= 'FROM '._DB_PREFIX_.'category, '._DB_PREFIX_.'category_lang '; $sql .= 'WHERE '._DB_PREFIX_.'category.id_category = '._DB_PREFIX_.'category_lang.id_category AND '._DB_PREFIX_.'category_lang.id_lang = '.$this->context->language->id; if ($Categories = Db::getInstance()->ExecuteS($sql)) //SAVE if(Tools::isSubmit('updatesettings')){ Alert ('Guardars'); } $smarty->assign('Categories', $Categories); return $this->display(__FILE__, 'AdminDAFFreeProduct.tpl'); } Edited June 12, 2013 by daalfu (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted June 12, 2013 Share Posted June 12, 2013 you want to run sql here: if(Tools::isSubmit('updatesettings')){ Alert ('Guardars'); } ? what is Alert() in php ? Link to comment Share on other sites More sharing options...
daalfu Posted June 15, 2013 Share Posted June 15, 2013 yes. I managed to add a new tab in product admin. Now I want to run a query when I click on a button. In order to do that, I wrote this: module.php: public function hookDisplayAdminProductsExtra() { global $smarty, $cookie; $product = $this->context->cookie->product; $smarty->assign('name', $this->l('Gifts')); $smarty->assign('Hint', $this->l('The customer will be allowed to pick a product from this category for free.')); $smarty->assign('credits', $this->l('Powered by BlazingArts')); //GET CATEGORIES $sql = 'SELECT '._DB_PREFIX_.'category.id_category, '._DB_PREFIX_.'category_lang.name '; $sql .= 'FROM '._DB_PREFIX_.'category, '._DB_PREFIX_.'category_lang '; $sql .= 'WHERE '._DB_PREFIX_.'category.id_category = '._DB_PREFIX_.'category_lang.id_category AND '._DB_PREFIX_.'category_lang.id_lang = '.$this->context->language->id; if ($Categories = Db::getInstance()->ExecuteS($sql)) //SAVE if(Tools::isSubmit('updatesettings')){ Alert ('Guardars'); 'I WANT TO RUN THE QUERY HERE.' } $smarty->assign('Categories', $Categories); return $this->display(__FILE__, 'AdminDAFFreeProduct.tpl'); } The problem is that when I click on the button, the page reloads and I cannot get the code executed. The alert() function is to display a msgbox. I put it in order to see if that portion of the code was being executed. But it is not. I am new in this, and I am not sure where should I write the code to be executed when clicking the button. Link to comment Share on other sites More sharing options...
vekia Posted June 15, 2013 Share Posted June 15, 2013 but you've got this function defined somewhere? i mean Alert(); Link to comment Share on other sites More sharing options...
daalfu Posted June 15, 2013 Share Posted June 15, 2013 No. It simply works for me. I used it several times in different parts of the code, and it always worked. Link to comment Share on other sites More sharing options...
vekia Posted June 15, 2013 Share Posted June 15, 2013 but this is php not javascript in php, by default, this function doesnt exist it's better to use print_r('something'); Link to comment Share on other sites More sharing options...
daalfu Posted June 16, 2013 Share Posted June 16, 2013 Haha. Good to know. As you see, I am new in php. Regarding my module, any idea where I should write the code in order to get the button to work? Link to comment Share on other sites More sharing options...
vekia Posted June 16, 2013 Share Posted June 16, 2013 code that you pasted should work, i mean if condition where you check the $_POST: tools::isSubmit('') use there query with Db object, something like: Db::getInstance()->Execute('Your Query Here"); Link to comment Share on other sites More sharing options...
jemmeli Posted June 24, 2013 Share Posted June 24, 2013 what if some one want to add more than one tabs under the product admin's tab , i think the hook DisplayAdminProductsExtra is not sufficient and can add just one tab ? Link to comment Share on other sites More sharing options...
vekia Posted June 24, 2013 Share Posted June 24, 2013 as far as i know you cant create (in ps 1.5) more than one displayAdminProductsExtra tab. it mean one module = one tab. 1 Link to comment Share on other sites More sharing options...
jemmeli Posted June 24, 2013 Share Posted June 24, 2013 (edited) yes , this is right and due to the prestashop's controller AdminProductsController.php that contains on the line 149 the following code: [/size][/font][/color] /* Adding tab if modules are hooked */ $modules_list = Hook::getHookModuleExecList('displayAdminProductsExtra'); and that's mean I can not add many tab per module but , is it possible to change the intern code of prestashop to make this happen ? Edited June 24, 2013 by jemmeli (see edit history) Link to comment Share on other sites More sharing options...
mosis Posted June 16, 2014 Share Posted June 16, 2014 Hi i need some help. I can display my module tab form etc .. in my admin panel but don't understand how to implement the save action. when i click on save button i have the following error: Fatal error: Call to undefined method SakanalMarquee::update() in C:\wamp\www\sakanal\classes\controller\AdminController.php on line 811 here is my admin controller code <?php class AdminSakanalMarqueeController extends ModuleAdminController { public function __construct() { $this->table = 'marquee'; $this->className = 'SakanalMarquee'; parent :: __construct(); // listing the rows $this->fields_list = array( 'id_marquee' => array('title' => '#'), 'message' => array('title' => 'Message'), 'active' => array('title' => 'Statut', 'active' => 'status' ), // ajouter 'active' => 'status' pour afficher le bouton ); // adding the form $this->fields_form = array( //'tinymce' => true, 'legend' => array( 'title' => $this->l('Message défilant'), 'image' => '../img/admin/contact.gif' ), 'input' => array( array( 'type' => 'textarea', 'label' => $this->l('Message'), 'name' => 'contenu', 'cols' => '60', 'rows' => '10', 'required' => true, ), array( 'type' => 'radio', 'label' => $this->l('Actif'), 'name' => 'active', 'required' => true, 'class' => 't', 'br' => false, 'values' => array( array('id' => '1', 'value' => 1, 'label' => $this->l('Oui')), array('id' => '0', 'value' => 0, 'label' => $this->l('Non')) ) ) ), 'submit' => array( 'title' => $this->l('Save'), 'class' => 'button' ) ); // action buttons $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'))); $this->actions = array('edit', 'delete'); //populate the field with good values if we are in an edition // foreach($this->fields_form["input"] as $inputfield){ // $this->fields_value[$inputfield["name"]] = $SakanalMarqueeObject->$inputfield["name"]; // } } // save method public function postProcess() { //echo Tools::isSubmit(""); echo $_POST['contenu'] ." " . $_POST['active']; parent::postProcess(); } // save public function processAdd() { //echo "saving ..."; parent::processAdd(); } public function processUpdate() { parent::processUpdate(); } } ?> Link to comment Share on other sites More sharing options...
Spir Posted October 17, 2014 Share Posted October 17, 2014 Here is a tutorial to get a working product edit tab: http://nemops.com/prestashop-products-new-tabs-fields/ Link to comment Share on other sites More sharing options...
Vipul Hadiya Posted February 17, 2015 Share Posted February 17, 2015 Let me tell you i am your fan. Is it possible to add multiple tab using single module? Link to comment Share on other sites More sharing options...
ChDUP Posted February 9, 2016 Share Posted February 9, 2016 Hi When I try to add my tab with public function hookDisplayAdminProductsExtra($params) { return 'test'; } It works , but a style="display:none;" is automaticly added on my new tab.Any idea about this ? thanks Link to comment Share on other sites More sharing options...
Recommended Posts