Take an Inside look at PrestaShop Modules

By - January 29, 2013
ShareTweet about this on Twitter11Share on Facebook34Share on Google+0Share on LinkedIn0

See the5 Comments

I. Module Installation and Configuration

a. Enhance your PrestaShop store with Modules

You’ve probably noticed that the instant you install PrestaShop, it comes fully equipped with a variety of modules. These modules deliver added functionality to your PrestaShop store such as payment processing, shipping solutions and marketing tools.

You can easily, add, install and configure these modules to fully customize your e-commerce store with the features you want.

b. Installing a module is easy!

All native modules are present in the solution during installation but only some are installed. To install a native module, all you need to do is login to your Back Office and navigate to the “Modules” tab. On a fresh install, you will find all of the native modules included in our solution. If you want to install a native module, simply locate it then click the “Install” button found on the right-hand side of the individual module block.

If you want to add a module that is separate from those included as native features inside PrestaShop, simply click the “Add new module” icon located at the top right-hand corner of your back office under the “Modules” tab, locate the module’s .zip file or tarball, then click “Upload this module.”

c. Module Configuration

After you install a module, you’ll want to make sure it’s configured properly. After all, a great module is useless until you correctly configure your modules’ settings.

Some modules, such as payment modules, require API credentials, a user ID and various other pieces of service information. In order to use these modules, you may need to sign up for a third-party subscription, after which you’ll be given the credentials needed for configuration. Other modules that do not require third-party subscription simply need to be optimized for your PrestaShop store. This process can be completed much the same way by clicking the configure tab after installation.

When configuration is complete, you will need to save your settings. Failing to do so will yield a non-working module.

If you have trouble finding a module, be sure to utilize our new Ajax Instant Search feature that can be found under the “Modules” tab in your PrestaShop Back Office.

d. Design your own modules

There are several ways to create your own module(s). First, you can customize a module that already exists, or you can design everything from scratch. Clearly, designing a module from scratch requires knowledge of the solution and the classes associated with modules (Module CarrierModule, PaymentModule, etc…).

A strong knowledge of older versions of PrestaShop will allow you to design a module capable of operating on all recent versions of PrestaShop, making the module more scalable and flexible.

II. Reusing an Existing Module

The easiest way to design your new module is by altering a module that already exists. When you are ready, simply copy and paste the module folder and rename it. Now, some steps are needed to ensure the proper functioning of your new module.

Structure of a module

After copying the module and changing the name of the directory, you need to change the name of the class file, the class name and its parameters.

To obtain a clear and organized file structure, our module, named “mymodule” for example, will be organized as follows:

  • Mymodule
    • css
    • img
      • logo.png
    • js
      • jquery.js
    • views
      • templates
        • back
          • config.tpl
        • front
          • about.tpl
    • config.xml
    • logo.gif
    • mymodule.php

You now have a class file with the same name as your module, mymodule.php. You just have to open it to change the code using a file editor like Notepad++. Many parameters can be added or changed, depending on the use of your module and how you want it to function.

You will need to structure the file “mymodule.php” like this:

<?php

/*
* License
*/

if (defined(‘_PS_VERSION_’) == false)
exit;

class MyModule extends Module
{
function __construct()
{
$this->name = ‘mymodule’;
$this->tab = ‘front_office_features’;
$this->version = 1.0;
$this->author = ‘My Name’;
$this->need_instance = 0;

parent::__construct();

$this->displayName = $this->l(‘My module’);
$this->description = $this->l(‘Description.’);
}

public function install()
{
return (parent::install() && $this->registerHook(‘rightColumn’));
}

public function hookRightColumn($param)
{
$this->smarty->display(’./views/templates/front/about.tpl’);
}
}

III. Starting from Scratch

You can also design your module from scratch. This would require that you clearly define all necessary parameters. These parameters are name, tab, version and author.

name: Serves as an internal identifier. Make it unique without special characters or spaces, and make sure to keep it lowercase.
tab: This is the title for the database table that will contain this module in the Back Office module list. You can use any name you want.
version: This is the version number for the module, displayed on the module list.
author: This is the author of the module, and it will be displayed on the PrestaShop module list.

Once you create your module, you can now add the final touches. You should include an Icon for your module which will be displayed next to the modules name. Having a logo attached to your module brings visible trust.

The icon file must respect these requirements:

In order to work with PrestaShop 1.5:

 IV. Publish and Sell your Module!

So, now that you’ve made an awesome PrestaShop module, what now? It’s simple! Start selling it on the PrestaShop Addons store today! Visit the PrestaShop Addons store, create a seller account, upload your module and set your prices. The module will go through a period of validation for security and bug testing. After it is validated and accepted, your module will be readily seen by thousands of customer’s each day. Using this service will help you publish your module so anybody can search, purchase and install your module in their PrestaShop store. If you chose to sell your module on PrestaShop Addons, you will be entitled to 70% of the total sales profit. PrestaShop will provide worldwide visibility to our 130,000+ merchant user base!

Visit the PrestaShop Addons store today!

Learn more about becoming a PrestaShop Addons Contributor

For more information on creating modules, consult our online documentation.

Receive articles like this in your inbox!

Subscribe to get the latest ecommerce news and tips sent directly to your email. Subscribe

ShareTweet about this on Twitter0Share on Facebook0Share on Google+0Share on LinkedIn0

See the5 Comments

Comments (5)

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>