:::: MENU ::::
Posts tagged with: Canvas

PrestaShop Canvas Module

This tutorial is about PrestaShop Canvas Module . This is a quite useful piece of code and a very important one too. let’s move forward and have a look.

First Step:

Create a directory as the same name as your module name in the following directory.

basedir/modules

In my case, my module name is helloworld so directory name will be helloworld. The directory structure will look like.

basedir/modules/helloworld

Second Step

Now we create file name helloworld.php in the following location. You module directory name and file name must be same.

basedir/modules/helloworld/helloworld.php

The file contains following code.

<?php

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

class Helloworld extends Module
{
  private $errors = null;
  public function __construct()
  {
    // Author of the module
    $this->author = 'qaisarsatti';
    // Name of the module ; the same that the directory and the module ClassName
    $this->name = 'helloworld';
    // Tab where it's the module (administration, front_office_features, ...)
    $this->tab = 'others';
    // Current version of the module
    $this->version = '1.0.0';
    //  Min version of PrestaShop wich the module can be install
    $this->ps_versions_compliancy['min'] = '1.5';
    // Max version of PrestaShop wich the module can be install
    $this->ps_versions_compliancy['max'] = '1.7';
    // OR $this->ps_versions_compliancy = array('min' => '1.5', 'max' => '1.6');
    //  The need_instance flag indicates whether to load the module's class when displaying the "Modules" page
    //  in the back-office. If set at 0, the module will not be loaded, and therefore will spend less resources
    //  to generate the page module. If your modules needs to display a warning message in the "Modules" page,
    //  then you must set this attribute to 1.
    $this->need_instance = 0;
    // Modules needed for install
    $this->dependencies = array();
    // e.g. $this->dependencies = array('blockcart', 'blockcms');
    // Limited country
    $this->limited_countries = array();
    // e.g. $this->limited_countries = array('fr', 'us');
    parent::__construct();
    // Name in the modules list
    $this->displayName = $this->l('Example');
    // A little description of the module
    $this->description = $this->l('Module Example');
    // Message show when you wan to delete the module
    $this->confirmUninstall = $this->l('Are you sure you want to delete this module ?');
    if ($this->active && Configuration::get('EXAMPLE_CONF') == '')
      $this->warning = $this->l('You have to configure your module');
    $this->errors = array();
  }
 
}

So, that’s it from this tutorial. I strongly believe there is always room for improvement. So I am open for any suggestion and feedback. Please feel free to leave hat you are thinking in the comments section below. Cheers.

Author: Qaisar Satti
Category: Prestashop
Last Modified: July 26, 2019