I
I
Indus Indusovich2015-10-15 20:18:45
PHP
Indus Indusovich, 2015-10-15 20:18:45

How to create a module for prestashop?

My task is to write export / import in xls for prestashop, I more or less understand how to implement the script itself, but integration into prestashop does not work. Everything is somehow very confusing, controllers, models, classes, OOP.
I'm trying to figure out how to create a tab in the admin panel for a module when installing it. It doesn't work, there is no documentation about the back office and modules for the back office, it's hard to understand on the forums what's what.
So far this

<?php
if (!defined('_PS_VERSION_'))
    exit;
 
class ProductsXls extends Module
{
    public function __construct()
    {
        $this->name = 'productsxls';
        $this->tab = 'administration';
        $this->version = '1.0';
        $this->author = 'Indus indusovich';
        $this->need_instance = 0;
        $this->ps_versions_compliancy = array('min' => '1.5', 'max' => '1.6');

 
    parent::__construct();
 
        $this->displayName = $this->l('Export/Import XLS');
        $this->description = $this->l('This module can export and import your products in excel (xls format) table');
 
        $this->confirmUninstall = $this->l('Are you sure you want to uninstall?');
 
    if (!Configuration::get('productsxls'))      
        $this->warning = $this->l('No name provided');
    }
    public function install()
    {
        $parent_tab = new Tab();
        $parent_tab->class_name = 'TabsAdminControllerName';
        $parent_tab->module = $this->name;
        $parent_tab->id_parent = 0;
        $languages = Language::getLanguages(false);
        foreach ($languages as $lang)
         $parent_tab->name[$lang['id_lang']] = 'Tab Name';
        $parent_tab->save();
    }
    
    public function uninstall()
    {
        if (!parent::uninstall() || !Configuration::deleteByName('productsxls'))
        {
            return false;
        }
        return true;
    }

    
}
?>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Semenov, 2016-12-08
Semenov

The simplest thing is to pick any similar module and see how it's done there.
You will see that there are a couple of functions that are performed in addition to what you gave in the example.
Such as displayForm()... getContent()... How to use the Helper class and other things
Read the \classes\module\Module.php class to find out what are there, also see what variables are there, etc.
The easiest thing is to buy a module and rewrite for yourself
Here is an example of an export module and its functions in only 1 file
krD9aO7HVpzZmp.jpg

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question