Jump to content

Adding new tab in Product Admin page like Features Tab, Attributes Tab etc. in PS Version 1.5.3


Recommended Posts

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!

  • Like 1
Link to comment
Share on other sites

  • 3 months later...

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

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

  • Like 4
Link to comment
Share on other sites

  • 4 weeks later...

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 by daalfu (see edit history)
Link to comment
Share on other sites

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

  • 2 weeks later...

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 ? :ph34r:

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

  • 11 months later...

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

  • 4 months later...
  • 3 months later...
  • 11 months later...
×
×
  • Create New...