Prestashop - 1.4 User's Guide

Browse online or download User's Guide for Software Prestashop - 1.4. Prestashop - 1.4 Developer's Guide User Manual

  • Download
  • Add to my manuals
  • Print
  • Page
    / 36
  • Table of contents
  • TROUBLESHOOTING
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 0
PrestaShop Developer Guide
The technical documentation is currently being updated. Some aspects
of it might not yet be fully updated. Do not hesitate to contact us if you
have any issue with the documentation.
Fundamentals
Concepts
You should be familiar with PHP and Object-Oriented Programming
before attempting to write your own module.
PrestaShop was conceived so that third-party modules could easily upon
its foundations, making it an extremely customizable e-commerce
software.
A module is an addition to PrestaShop that enables any developer to add
the following:
Provide additional functionality to PrestaShop.
View additional items on the site (product selection, etc..).
Communicate with other e-commerce players (buying guides,
payment platforms, logistics...)
etc...
The company behind PrestaShop provides more than 100 modules for free
with the tool itself, enabling you to launch your business quickly and for
free.
More than 750 add-ons are also available at the official add-ons site.
These additional modules were built by the PrestaShop comapny or
members of the PrestaShop community, and are sold at affordable prices.
As a developer, you can also share your modules on this site, and receive
70% of the amounts associated with the sale of your creations. Sign up
now!
PrestaShop's technical architecture
PrestaShop is based on a 3-tier architecture:
Object/data. Database access is controlled through files in the
"classes" folder.
Data control. User-provided content is controlled by files in the
root folder.
Design. All of the theme's files are in the "themes" folder.
Page view 0
1 2 3 4 5 6 ... 35 36

Summary of Contents

Page 1 - Fundamentals

PrestaShop Developer Guide The technical documentation is currently being updated. Some aspects of it might not yet be fully updated. Do not hesitate

Page 2

after said creation/duplication. updateproduct AdminProducts.php No Called when a product is update with a new picture, right after said update.

Page 3 - What is a PrestaShop module

to. Carriers Hook name File location Visible Description updateCarrier AdminCarriers.php No Called during a carrier's update, right after

Page 4 - A list of PrestaShop hooks

Module file tree All PrestaShop modules are found in the /modules folder, which is at the root of the PrestaShop main folder. This is true for both d

Page 5

there's only one such file, it is good practice to give it the same name as the folder and main file: mymodule.tpl. The mymodule.php file must st

Page 6

public function __construct() Defines the class' constructor. $this->name = 'mymodule'; $this->tab = 'Test'; $this-&g

Page 7

public function install() { return ( parent::install() ); } In this first and extremely simplistic incarnation, this method is useless, since a

Page 8

PrestaShop automatically creates a small config.xml file in the module's folder, which stores a few configuration information. You should NEVER

Page 9

if ( parent::install() == false OR !$this->registerHook( 'leftColumn' ) ) return false; return true; We changed the original line to a

Page 10

In the transplantation form, find "My module" in the modules drop-down menu, then choose "Left column blocks" in the "Hook in

Page 11 - Creating a PrestaShop module

Displaying content Now that we have access to the left column, we should display something there. As said earlier, the content to be displayed in the

Page 12 - Basic structure of a module

This is the same principle as the Model–view–controller (MVC) architecture, only in a simpler and more accessible way. Our developer team chose not t

Page 13

basic line, and call that file from mymodule_page.php, which will add the theme's header, footer, etc. You should strive to use explicit and rec

Page 14

If you make multiple changes and reloads to your homepage, it may seem said changes do not apply. This is because Smarty caches a compiled version of

Page 15

$mymodule = new MyModule(); $message = $mymodule->l( 'Welcome to my shop!' ); $smarty->assign( 'messageSmarty', $message );

Page 16 - Hooking a module

currencies The various available currencies. id_currency_cookie ID of the current currency. currency Currency object (currently used currency).

Page 17

Strings in TPL files will need to be turned into dynamic content, which Smarty will replace by the translation for the chosen language. In our sample

Page 18

using the l() method), simply find your module in the list (use the browser's in-page search), and fill the empty fields. Once all strings for y

Page 19 - Displaying content

Now that we have a translation, we can click on the French flag in the front-office (provided the language has indeed been installed), and get the exp

Page 20

protected $fieldsValidate = array( 'test' => 'isGenericName' ); protected $table = 'test'; protected $identifie

Page 21 - Using Smarty

<form action="' . $currentIndex . '&submitAdd' . $this->table . '=1&token=' . $this->token . &ap

Page 22

Some forums keep certain threads pinned on top of all threads; they contain some useful information, so be sure to read them through. Our bug-tracker

Page 23 - Module translation

Database schema You can download the PrestaShop 1.4 SQL schema in PNG form (1 Mb), or in the original MySQL Workbench file format (you will need MySQ

Page 24

Variable names 1. Corresponding to data from databases: $my_var 2. Corresponding to algorithm: $my_var 3. The visibility of a member variable does

Page 25

10. When a method/function returns a boolean and the current method/function return depends on it, the if statement has to be avoided 11. 12. pub

Page 26

Objects / Classes 1. Object name must be singular 2. 3. class Customer 4. Class name must follow the CamelCase practice except that the first le

Page 27 - AdminTest.php

7. $a = 17 + 23; // A comment inside my exemple function 8. Outside funcions and methods, only the "/" and "/" comment tags are

Page 28 - Troubleshooting

Tags 1. An empty line has to be left after the PHP opening tag 2. 3. <?php 4. 5. require_once('my_file.inc.php'); 6. The PHP end

Page 29 - Summary

Security 1. All user datas (datas entered by users) have to be casted. 2. 3. $data = Tools::getValue('name'); 4. 5. $myObject->st

Page 30

2. 3. SELECT `firstname` 4. FROM `'. _DB_PREFIX_.'customer` 5. Back quotes ("`") must be used around field names and table na

Page 31

enables you to handle the module's display in various ways, according to the current theme. Let's see an example with PrestaShop's bloc

Page 32

When one of the site's pages is loaded, the PrestaShop engine check which are the modules to call for each of the hooks that make up the page. He

Page 33

Ideal location for the content of a tab that has been defined using the productTab hook. Cart Hook name File location Visible Description cart C

Page 34

authentication authentication.php No Called right after the client identification, only if the authentication is valid (e-mail address and password

Page 35

backBeforePayment order.php No Called when displaying the list of available payment solutions. Ideal location to redirect the user instead of displ

Page 36

"Payment accepted". updateOrderStatus Class: OrderHistory.php No Called when an order's status is changed, right before it is actua

Comments to this Manuals

No comments