skip to Main Content

I’m new on developing module of Prestashop and I use version of 1.7.4.2. I’m trying to developing a module and I have to create a custom tab in left menu in back office. I tried this way which is in the Prestashop official documentation(https://devdocs.prestashop.com/1.7/modules/concepts/controllers/admin-controllers/tabs/). But custom tab doesn’t visible in the back office. Here I add my code and my file names. Can anyone help me about where is my mistake? Thank you so much.

My Files

driveorder

-driveorder.php

-logo.png

-controllers

–admin

—AdminDriveOrder.php

And there is driveorder.php file which is I created custom tab.

<?php
if (!defined('_PS_VERSION_'))
    exit;

class driveorder extends Module
{
    public function __construct()
    {
        $this->name = 'driveorder'; /* This is the 'technic' name, this should equal to filename (mycustommodule.php) and the folder name */
        $this->tab = 'administration'; /* administration, front_office_features, etc */
        $this->version = '1.0.0'; /* Your module version */
        $this->author = 'Sertac Bazancir'; /* I guess it was clear */
        $this->need_instance = 0; /* If your module need an instance without installation */
        $this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_); /* Your compatibility with prestashop(s) version */
        $this->bootstrap = true; /* Since 1.6 the backoffice implements the twitter bootstrap */

        parent::__construct(); /* I need to explain that? */

        $this->displayName = $this->l('Drive Order'); /* This is the name that merchant see */
        $this->description = $this->l('Google Drive integration for virtual products.'); /* A short description of functionality of this module */

        $this->confirmUninstall = $this->l('Are you sure you want to uninstall?'); /* This is a popup message before the uninstall */

        $this->tabs = array(
            array(
                'name' => 'Drive Order', // One name for all langs
                'class_name' => 'AdminDriveOrder',
                'visible' => true,
                'parent_class_name' => 'SELL'
            )
        );

    }

    public function install(){
        if (Shop::isFeatureActive()){
            Shop::setContext(Shop::CONTEXT_ALL);
        }
        $sql = "CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."drive_product`(
        `id_product` INT(10) NOT NULL PRIMARY KEY,
        `id_drive` VARCHAR(255) NOT NULL )";
        $result = Db::getInstance()->Execute($sql);
        if (!parent::install() OR !$result OR !$this->registerHook('actionPaymentConfirmation')){
            return false;
        }
        return true;
    }

    public function uninstall(){
        $sql = "DROP TABLE `"._DB_PREFIX_."drive_product`";
        $result = Db::getInstance()->Execute($sql);
        if (!parent::uninstall() OR !$result OR !Configuration::deleteByName('driveorder')){
            return false;
        }
        return true;
    }

    public function hookActionPaymentConfirmation($params){
        global $smarty;
    }
}
?>

2

Answers


  1. Your mistake is here:

    'parent_class_name' => 'SELL'
    

    Try this:

    'parent_class_name' => 'AdminParentOrders'
    
    Login or Signup to reply.
  2. You also have to name your controller file AdminDriveOrderController.php instead of AdminDriveOrder.php

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search