Jump to content

add admin tab


Recommended Posts

Hi

 

I'm trying to add an admin tab..

 

http://doc.prestashop.com/display/PS15/Creating+a+PrestaShop+module#CreatingaPrestaShopmodule-CreatingaPrestaShopmodule

 

Creating the module's back-office tab, and its class

 

Have followed the instructions, and now I need to add the tab

 

"Put the files online, then create the tab by going to the "Employee" tab, then its "Tabs" sub-tab. Click the "Add new" button, and fill-in the fields with the class' name, "AdminTest". Do not confuse "class" with "modules"! Choose an icon (like one from the FamFamFam icon pack: http://www.famfamfam.com/lab/icons/silk/), choose where the tab should go, and save. You are set! Now start customizing it to your needs!"

 

But I don't think it gives sense? I can't find any Employee tab in the backoffice section

Link to comment
Share on other sites

Ok

 

Have now added this in the db

 

table: ps_tab

 

parent_id: 0

class_name: AdminTest

module: Test

position: 12

active: 1

 

I still don't see any new tab?! I can add the menu under a parent, but can't add it as a primary tab in the menu bar?

 

Edit: I need to install the menu from a module installation

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

maybe this will be a little more clear:

 

12.06.2012-14.50.46.png

http://screencast.com/t/O9lyxfea

 

 $this->name = 'multidomainpro40';

 if( !$this->adminInstall())
  return FALSE;

 

here is an example of adding the admin tab dynamically via your module code(1.4 but should also work in 1.5)...

 

private function adminInstall()
{
 if (!$idTab = Tab::getIdFromClassName('AdminContactMultiShop')) {
  $tab = new Tab();
  $tab->class_name = 'AdminContactMultiShop';
  $tab->module = $this->name;
  $tab->id_parent = 9;
  $languages = Language::getLanguages(false);
  foreach ($languages as $lang)
$tab->name[$lang['id_lang']] = 'PrestaMultiShop';
  $res &= $tab->save();
  $tab->name[(int)(Configuration::get('PS_LANG_DEFAULT'))] = $this->l('AdminContactMultiShop');
 }
 return TRUE;
}

 

uninstall code:

 

 $tab = new Tab(Tab::getIdFromClassName('AdminContactMultiShop'));

 $tab->delete();

Edited by elpatron (see edit history)
  • Like 1
Link to comment
Share on other sites

The code is not working..

 

The tab is not installed.. I need to add a new tab with it's own submenu / dopdownmenu

 

class Dynaccount extends Module {
const TBL_CACHE = 'dynaccount_cache';
const TBL_LOG = 'dynaccount_log';

public function __construct(){
	$this->name = 'dynaccount';
	$this->tab = 'Dynaccount';
	$this->version = 1.0;
	$this->author = 'Dynaccount';
	$this->need_instance = 0;

	parent::__construct();

	$this->displayName = $this->l('Dynaccount');
	$this->description = $this->l('Dynaccount API integration');
}

private function adminInstall(){
	if(!$idTab = Tab::getIdFromClassName('AdminDynaccountCache')){
		$tab = new Tab();
		$tab->class_name = 'AdminDynaccountCache';
		$tab->module = $this->name;
		$tab->id_parent = 0;
		$languages = Language::getLanguages(false);
		foreach($languages as $lang){
			$tab->name[$lang['id_lang']] = $this->tab;
		}

		$res &= $tab->save();
		$tab->name[(int)(Configuration::get('PS_LANG_DEFAULT'))] = $this->l('AdminDynaccountCache');
	}

	return true;
}

public function install(){
	if(!parent::install() || !$this->registerHook('actionPaymentConfirmation') || !$this->registerHook('actionProductAdd')){
		return false;
	}

    $this->adminInstall();

	Db::getInstance()->Execute("CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_.self::TBL_CACHE."` ("
		."`id` int(10) unsigned NOT NULL AUTO_INCREMENT,"
		."`is_booked` tinyint(1) unsigned NOT NULL,"
		."`time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,"
		."`order_id` int(10) unsigned NOT NULL,"
		."`invoice_number` int(10) unsigned NOT NULL,"
		."`total` decimal(8,2) NOT NULL,"
		."`vat` decimal(8,2) NOT NULL,"
		."PRIMARY KEY (`id`),"
		."KEY `is_booked` (`is_booked`))");

	Db::getInstance()->Execute("CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_.self::TBL_LOG."` ("
		."`id` int(10) unsigned NOT NULL AUTO_INCREMENT,"
		."`time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,"
		."`msg` varchar(255) NOT NULL,"
		."PRIMARY KEY (`id`))");

	return true;
}

public function hookActionProductAdd($params){
	$params['order_id'] = 1;

	if($order = $this->get_order($params['order_id'])){
		$this->put_cache($params['order_id'], $order);
	}

	$this->update_cache();
}

public function hookActionPaymentConfirmation($params){

}
}

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

@ elpatron

 

Ok, I have given up trying to add a new menu point, but instead adding it as a child to "Orders"

 

This code works in version 1.5, but not in 1.4

 

Could you please help? :)

 

if(!Tab::getIdFromClassName('AdminDynaccountCache')){
$tab = new Tab();
$tab->class_name = 'AdminDynaccountCache';
$tab->id_parent = 10;
$tab->module = $this->name;
$languages = Language::getLanguages(false);
foreach($languages as $lang){
	$tab->name[$lang['id_lang']] = 'Dynaccount cache';
}
$tab->save();
}

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

  • 3 months later...
  • 2 months later...

same problem like as Duozhasht

 

when creating the new tab BO when click the that BO tab then

 

Controller not found

The controller adminnotfound is missing or invalid.

 

this type of error occur in backoffice please help me remove the error

 

I have the same error. I am still searching. If you get it right please share

Link to comment
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
×
×
  • Create New...