Jump to content

Admin controller Page not Found


Recommended Posts

Im working on my own module, that is supposed to work with controller in BO. When I install this module, my custom tab shows up in admin menu, but when I click on link, I get "Page not found". I am creating this module with help of a few articles on net. Can anyone help me by pointing out what am I doing wrong? I'm starting to be in dead end...

Thing is, that I expect to see at least "Hello world!" as is in tpl file that I'm calling in initContent(), instead I get this "Page not found". Even no error or exception (I have debug: ON and Dev_mode: true

When I try to var_dump("hi there!");die(); on the beginning of __construct() in controller, there's no change. Still "Page not found".

Edit: oh yes, and URL that is being called by menu tab is https://mydomain.com/admin_dev/index.php?controller=AdminWarehouseAddress&token=17f4840de8ab769b454601993723b96a

 

structure

 

This is my main class skl_warehouseaddress.php

if (!defined('_PS_VERSION_')) {
    exit;
}

class skl_warehouseaddress extends Module {

    public function __construct() {
        $this->name = 'skl_warehouseaddress';
        $this->tab = 'shipping_logistics';
        $this->version = '1.0.0';
        $this->author = 'Jan Prokeš';
        $this->need_instance = 0;
        $this->ps_versions_compliancy = array('min' => '1.7', 'max' => _PS_VERSION_);
        $this->bootstrap = TRUE;

        parent::__construct();

        $this->displayName = $this->l('SKL Warehouse Addresses');
        $this->description = $this->l('Warehouse address manager');

        $this->confirmUninstall = $this->l('Are you sure you want to uninstall?');

        if (!Configuration::get('SKL_WAREHOUSEADDRESS_NAME'))
            $this->warning = $this->l('No name provided');
    }

    public function install() {

        Db::getInstance()->execute('
        CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'warehouseaddress` (
        `id_stock_position` int(11) unsigned NOT NULL AUTO_INCREMENT,
        `id_stock_available` INT( 11 ) UNSIGNED NOT NULL,
        `code` varchar(32) NOT NULL,
        PRIMARY KEY (`id_stock_position`),
        UNIQUE `UNIQUE_POSITION_CODE` ( `code` )
        ) ENGINE = ' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET = utf8;
            ');
        
        if(parent::install()){
            if($this->installTab('IMPROVE', 'AdminWarehouseAddress', 'Warehouse Addresses')){
                return true;
            }
        }
    }

This is controller

class AdminWarehouseAddressController extends ModuleAdminController {
    
    
    public function __construct() {
        parent::__construct();
        $this->context = Context::getContext();        
    }

    public function initContent() {
        parent::initContent();
        $this->context->smarty->assign(array());
        $this->setTemplate('view.tpl');
    }

    public function renderView() {
        return parent::renderView();
    }

    public function renderList()
    {
        return parent::renderList();
    }
}

this is model

class WarehouseAddress extends ObjectModel {

    public $id_stock_position; /** @var int ID pozice */
    public $id_stock_available; /** @var int ID produktu na pozici */
    public $code; /** @var varchar EAN/SKU */

    /**
     * @see ObjectModel::$definition
     */
    public static $definition = array(
        'table' => 'warehouseaddress',
        'primary' => 'id_stock_position',
        'multilang' => false,
        'fields' => array(
            'id_stock_available' => array(
                'type' => self::TYPE_INT, 'validate' => 'isUnsigned', 'required' => true),
            'code' => array(
                'type' => self::TYPE_STRING, 'size' => 32, 'required' => true)
        )
    );

}

and this is tepl file, that I expect to see

<section >
    <div>Hello world !</div>
</section>

 

Edited by Rail Balco (see edit history)

Share this post


Link to post
Share on other sites

Ok so I'll answer myself...

When installing tabs I assigned wrong tabParentName, this is correct way of how to install tabs...
 

public function installTab($className, $tabName, $tabParentId, $tabParentName = false)
    {
        $tab = new Tab();
        $tab->active = 1;
        $tab->class_name = $className;
        $tab->name = array();

        foreach (Language::getLanguages(true) as $lang) {
            $tab->name[$lang['id_lang']] = $tabName;
        }

        if ($tabParentName) {
            $tab->id_parent = (int) Tab::getIdFromClassName($tabParentName);
        } else {
            $tab->id_parent = $tabParentId;
        }

        $tab->module = $this->name;

        return $tab->add();
    }

 

Share this post


Link to post
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...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More