LogoLogo
Homepage
  • Documentations for PrestaShop 1.4
  • English documentation 1.4
    • Getting Started
    • Updating PrestaShop
    • User Guide
      • Training
      • Customizing your shop
      • Browsing the front-office
      • Connecting to the PrestaShop back-office
      • Adding Products and Product Categories
      • A Look inside the Catalog
      • Managing Customers
      • Managing Orders
      • Managing Payment Methods
      • Managing Shipping
      • Understanding Statistics
      • Managing Modules
      • Managing Employees
      • Understanding the Preferences
      • Exploring PrestaShop's Tools
      • PrestaShop Support
    • System Administrator Guide
    • Developer Guide
      • Developer tutorials
        • Using the REST webservice
          • Chapter 1 - Creating Access to Back Office
          • Chapter 2 - Discovery - Testing access to the web service with the browser
          • Chapter 3 - First steps - Access the Web service and list client
            • 3.1 - Access the web service
            • 3.2 - Handling errors
            • 3.3 - List clients
          • Chapter 4 - Retrieve Data - Retrieving a Client
          • Chapter 5 - Modification - Update client
          • Chapter 6 - Creation - Remote Online Form
          • Chapter 7 - Removal - Remove customer accounts from the database
          • Chapter 8 - Advanced Use
          • Cheat-sheet - Concepts outlined in this tutorial
        • Understanding and using hooks
        • Synchronization via Hooks
        • Modules, Classes and Controller Override
        • Modules, Override, Web Service
        • Db class good practices for Prestashop 1.4
        • Carrier modules - functions, creation and configuration
        • Creating your own payment module
        • Accelerated Security Course - Episode 1 - Never Trust Foreign Data
        • Accelerated Security Course - Episode 2 - SQL Injections
        • Accelerated Security Course - Episode 3 - XSS
        • Accelerated Security Course - Episode 4 - CSRF
      • Fundamentals
      • Creating a PrestaShop module
      • Development standard
      • Public and overloadable methods
      • Web-service reference
      • How to use the forge to contribute to PrestaShop
      • Rocky's guides
        • PrestaShop 1.4.3 Development Guide
          • Architecture
          • Overriding Files
          • Creating Modules
          • Cookie Structure
          • Database Structure
        • PrestaShop 1.4.3 Performance Guide
    • Designer Guide
      • Coding a theme
      • Design tips
      • Implementing layered navigation in a theme
    • Troubleshooting
    • FAQ
    • User contributions
    • Documentation PDFs
  • Documentation française 1.4
    • Guide de démarrage
    • Mettre à jour PrestaShop
    • Guide de l'utilisateur
      • Formation
      • Personnaliser votre boutique
      • Se connecter au back-office de Prestashop
      • Ajouter des produits et des catégories de produits
      • Un aperçu du catalogue
      • Gérer les clients
      • Gérer les commandes
      • Gérer les méthodes de paiement
      • Gérer le transport
      • Comprendre les statistiques
      • Gérer les modules
      • Gérer les employés
      • Comprendre les préférences
      • Explorer les outils de PrestaShop
      • Obtenir de l'aide
    • Guide de l'administrateur système
    • Guide du développeur
      • Fondamentaux
      • Créer un module PrestaShop
      • Tutoriels pour développeurs
        • Tutoriel Webservice REST
          • Chapitre 1 - Mise en place - Création des accès dans le Back Office
          • Chapitre 2 - Découverte - Tester l'accès au service web avec le navigateur
          • Chapitre 3 - Premiers pas - Accéder au service web et lister les clients
            • 3.1 Accéder au service web
            • 3.2 Gestion des erreurs
            • 3.3 Lister les clients
          • Chapitre 4 - Récuperer des données : Récupérer un client
          • Chapitre 5 - Modification : Mettre à jour un client
          • Chapitre 6 - Création : Formulaire d'ajout à distance
          • Chapitre 7 - Suppression : Retirer des comptes client de la base
          • Chapitre 8 – Utilisation avancée
          • Chapitre 9 - Gestion des images
          • Chapitre 10 - Gestion des prix
          • Mémento : Notions énoncées dans ce tutoriel
        • Mieux comprendre et utiliser les hooks
        • La synchronisation via les Hooks
        • Surcharge et override
        • Modules, surcharge, web service
        • Les bonnes pratiques de la classe Db sur Prestashop 1.4
        • Les modules transporteurs - fonctionnement, création, configuration
        • Cours de sécurité accéléré no. 1 - Never trust foreign data
        • Cours de sécurité accéléré no. 2 - Injections SQL
        • Cours de sécurité accéléré no. 3 - XSS
        • Cours de Sécurité accéléré no. 4 - CSRF
    • Guide du designer
      • Conseils en design
      • Créer un thème
    • Guide du Vendeur
    • Import Wiki FR
      • Dépannage
        • Changer la taille maximum de téléchargement de fichiers
        • Comment ajouter une page à PrestaShop
        • Générer le fichier .htaccess par Prestashop pour avoir des URLs simplifiées
        • Générer un nouveau mot de passe manuellement
        • Import CSV
        • Personnalisation des mails clients
        • Problème d'allocation mémoire chez 1&1
        • Problème pour se connecter après avoir effacé une langue
        • Votre site ne répond plus, une page blanche s’affiche
      • Fidéliser les Clients
      • Gestion des Taxes
      • Installer Un Module
      • Sauvegarder votre Base de Données
    • PDF de la documentation
    • Contributions des utilisateurs
    • Questions fréquentes
  • Documentación española 1.4
    • Introducción
    • Actualización de PrestaShop
    • Guía de Usuario
      • Entrenamiento
      • Personalización de su tienda
      • Exploración del front-office
      • Conexión al back-office PrestaShop
      • Añadir Productos y Categorías de Productos
      • Una Mirada Dentro del Catálogo
      • Gestión de Clientes
      • Gestión de Pedidos
      • Gestión de Métodos de Pago
      • Gestión de Envío
      • Comprensión de las Estadísticas
      • Gestión de Módulos
      • Gestión de Empleados
      • Comprensión de Preferencias
      • Exploración de las herramientas de PrestaShop
      • Soporte PrestaShop
    • Guía del Administrador del Sistema
    • Guía del Desarrollador
      • Aspectos Fundamentales
      • Creación de un módulo de PrestaShop
      • Estándares de desarrollo
      • Manuales de desarrollador
        • Utilización del servicio web REST
          • Capítulo 1 - Creación de Acceso al Back Office
          • Capítulo 2 - Descubrimiento - Pruebas de acceso al servicio web con el navegador
          • Capítulo 3 - Primeros pasos - Acceso al servicio Web y lista de clientes
            • 3.1 - Acceso al servicio web
            • 3.2 - Manejo de errores
            • 3.3 - Enumeración de clientes
          • Capítulo 4 - Recuperación de datos - Recuperación de un cliente
          • Capítulo 5 - Modificación - Actualización de cliente
          • Capítulo 6 - Creación - Formulario En Línea Remoto
          • Capítulo 7 - Eliminación - Eliminar cuentas de clientes de la base de datos
          • Capítulo 8 - Uso avanzado
        • Comprensión y uso de hooks
        • Sincronización a través de Hooks
        • Módulos, Reemplazo, Servicio Web
        • Módulos, Clases y Reemplazo del Controlador
        • Buenas prácticas de Clase DB para Prestashop 1.4
        • Módulos de transportistas - funciones, creación y configuración
        • Curso Acelerado de Seguridad - Episodio 1 - Nunca Confíe en Datos Exteriores
        • Curso Acelerado de Seguridad - Episodio 2 - Inyecciones SQL
        • Curso Acelerado de Seguridad - Episodio 3 - XSS
        • Curso Acelerado de Seguridad - Episodio 4 - CSRF
      • Referencia del servicio web
    • Guía de Diseñador
      • Codificación de un tema
      • Consejos de Diseño
    • Solución de problemas
    • Preguntas Frecuentes
Powered by GitBook
On this page
  • Overriding Core
  • Web service
  • How to choose?

Was this helpful?

  1. English documentation 1.4
  2. Developer Guide
  3. Developer tutorials

Modules, Override, Web Service

PreviousModules, Classes and Controller OverrideNextDb class good practices for Prestashop 1.4

Last updated 4 years ago

Was this helpful?

This article was written by Damien Metzger, and was first published .

Ever since the creation of PrestaShop, our modules have been the easiest and most powerful way for merchants to customize their stores. Yet PrestaShop v1.4 released two new possibilities for your store and your business to go further, faster, and be more efficient : let us introduce you to how to override the core and use the web service.

Overriding Core

Overwriting allows all developers, whether they are freelancers or work for a web agency, to change the behavior of classes that make up the PrestaShop core—without modifying it! You can thus also extend the PrestaShop code, either to replace it with its own code, optimized to meet the store’s needs, for example, or simply to add instructions to the existing ones.

Now with version 1.4, a developer who wishes to modify a PrestaShop class no longer touches the core files. Instead, they create a file in the folder /override that appears at the root of the software.

Example

To add a message such as “Hello world!” each time you load a product—which is perfectly useless, of course—you just need to place the file Product.php in the folder /override/classes, and in the file you must write:

class Product extends ProductCore
{
  public function __construct($id_product = NULL, $full = false, $id_lang = NULL)
  {
    echo 'Hello World !';
    parent::__construct($id_product, $full, $id_lang);
  }
}

Thus, a technician who works on your store can immediately identify the modifications made. Furthermore—and this is really important!—updating PrestaShop to a future, improved version will be considerably easier. You will just have to test these overridden classes’ compatibility rather than doing a tedious and time-consuming diff with files from the new version.

If you’re not comfortable with the concept of Inheritance (object-oriented programming)—which is necessary for creating a child class—you should take a look at some information on Wikipedia: )

Web service

Web services are increasingly present in all areas of computing, and are essential to the ongoing evolution of the web, and therefore essential to e-commerce as well.

When applied to PrestaShop, web services enable developers, whether familiar or not to developing with PrestaShop, to remotely retrieve and send information to the store without having access to the software code!

The technology that PrestaShop has chosen for its web service is REST. The principal advantage of this style of architecture is that it’s based on the XML format. The XML files exchanged between the client and the web service are made to be used intuitively, without first having to read several pages of documents specific to the application. A developer familiar with this technology can easily use the service, and a beginner will adapt very quickly.

PrestaShop offers developers a PHP library which allows them to use the web service without needing to make XML files by hand. Various example codes are also offered to better understand the different options.

How to choose?

While these three tools let everyone modify the behavior and add features to a store, they also have three very different applications. Choosing the right tool is therefore not to be taken lightly.

If you want to make specific changes to your store, which will never be used elsewhere, then in most cases choosing to overwrite the core—classes or controllers—will be the best solution. It is indeed the most natural and efficient way to make changes. You will nevertheless need to monitor its operation after an update, especially if corrections were made to the features you have overwritten, or if some of them are outdated.

Last but not least, the web service is the best choice when the store must interact with external software. This technique not only allows the third party application to communicate with the store without adding code, but it can also protect confidential information by limiting rights.

A step-by-step guide on the web service is available on PrestaShop’s documentation site:

You can find out more about REST on Wikipedia:

What if instead of making changes to your one store, you intend to package and distribute your changes? For example, you may wish to place them on the website for downloads. In this case, you need to choose a module. Using a module also helps keep things clean: its hook system lets us immediately and easily see what changes were made to every event started by the store. Someone looking at the code, in order to use or improve it, could immediately identify the module’s scope of action.

on May 4th, 2011, on the PrestaShop blog
http://en.wikipedia.org/wiki/Inheritance_(object-oriented_programming
http://doc.prestashop.com/
http://en.wikipedia.org/wiki/Representational_State_Transfer
PrestaShop Addons