Prestashop Create Admin Controller inside Admin Folder

AdminController inside Root Admin Folder
In Prestashop, We need to store our manually create Admin Controller in Prestashop Database. We must add our Admin Controller class in tab table also.
On the root there is admin folder inside the controllers folder. Inside admin folder create your controller file for eg. like AdminNameController.php and save it. After that Register your Controller in Database -> Tab table.
  • You need to define id for tab in (id_tab) field manually according to increment order.(eg: means if id_tab value is 3 you must set id_tab value 4).
  • Parent id (id_parent) is used for make your controller as child for any parent like under SELL Parent (for SELL id_parent set to 2).
  • Next is Position where do you define the Position of your Controller in ADmin Menu Bar.(like if you set position where you want to show the controller in menu bar count from 0 to end menu in the Sell Tab of menu bar and set according to you in between them or last or on first position.
  • Back-Office-Sidebar-Menu-Bar
    Educational Purpose
  • After that define the class_name for your controller like AdminYourController (eg: AdminCustomMenu).
  • And the last active the controller and set to 1 in active column.
You controller code is.
class AdminNameController extends AdminController
{
 public function __construct()
 {
  parent::__construct();
  table = 'tablename';
  bootstrap = true;
 }
 public function viewAccess()
 {
  return true;//for view in controller
 }
 public function initContent()
 {
  $content=$smarty->fetch(_PS_THEME_DIR_.'templates/foldername/tplname.tpl');
  $this->context->smarty->assign(array('content' => $this->content . $content));
 }
}

  • Define your tpl in Theme folder "templates/foldername/tplname.tpl". According to tpl destination.
  • And write simple word like "hello" in tpl and go to admin area and click on your Newly created controller and check you hello word is appear there. Thats it you created controller successfully. 

Comments

Post a Comment

If you have any error, bug related to your Prestashop website, Let me know

Popular posts from this blog

Prestashop Pass Controller Variables To TPL

Prestashop PDF Download Error