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
  • Public and overloadable methods
  • ObjectModelCore (ObjectModel.php)
  • ToolsCore (Tools.php)
  • AdminTabCore (AdminTab.php)
  • PDFCode (PDF.php)
  • ConfigurationCore (Configuration.php)
  • CookieCore (Cookie.php)
  • DbCore (Db.php)
  • LinkCore (Link.php)
  • MailCore (Mail.php)
  • FrontControllerCore (FrontController.php)

Was this helpful?

  1. English documentation 1.4
  2. Developer Guide

Public and overloadable methods

PreviousDevelopment standardNextWeb-service reference

Last updated 4 years ago

Was this helpful?

Table of contents

Public and overloadable methods

PrestaShop makes it possible to override many of its core functions, using overriding. But overriding cannot be done if you do not know which method to replace. This list should help you.

You can learn more about overriding PrestaShop by reading the following articles:

  • ""

  • "".

If you do not want to replace a method, but simply add to it, remember to call the parent eponymous method somewhere in your method.

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); }}

ObjectModelCore (ObjectModel.php)

This is the main object from PrestaShop object model. Any overriding of its methods is bound to influence how all other classes and methods act. Use carefully.

Method name and parameters

Description

getValidationRules($className = _CLASS_)

Returns object validation rules (fields validity).

getFields()

Prepare fields for ObjectModel class (add, update).

__construct($id = NULL, $id_lang = NULL)

Build object.

save($nullValues = false, $autodate = true)

Save current object to database (add or update).

add($autodate = true, $nullValues = false)

Save current object to database (add or update).

add($autodate = true, $nullValues = false)

Add current object to database.

update($nullValues = false)

Update current object to database.

delete()

Delete current object from database.

deleteSelection($selection)

Delete several objects from database.

toggleStatus()

Toggle object status in database.

validateFields($die = true, $errorReturn = false)

Check for fields validity before database interaction.

ToolsCore (Tools.php)

This class relates to the PrestaShop set of tools, found in the admin's Tools tab.

Method name and parameters

Description

passwdGen($length = 8)

Random password generator.

redirect($url, $baseUri = _PS_BASE_URI_)

Redirect user to another page.

redirectLink($url)

Redirect url wich allready PS_BASE_URI.

redirectAdmin($url)

Redirect user to another admin page.

getProtocol($use_ssl = null)

getHttpHost($http = false, $entities = false)

Return the <b>current</b> host used, with the protocol (http or https) if $http is true. This function should not be used to choose http or https domain name. Use Tools::getShopDomain() or Tools::getShopDomainSsl instead.

getShopDomain($http = false, $entities = false)

Returns domain name according to configuration and ignoring ssl.

getShopDomainSsl($http = false, $entities = false)

returns domain name according to configuration and depending on ssl activation.

getServerName()

Get the server variable SERVER_NAME.

getRemoteAddr()

Get the server variable REMOTE_ADDR, or the first ip of HTTP_X_FORWARDED_FOR (when using proxy).

usingSecureMode()

Check if the current page use SSL connection on not.

getCurrentUrlProtocolPrefix()

Get the current url prefix protocol (https/http).

secureReferrer($referrer)

Secure an URL referrer.

getValue($key, $defaultValue = false)

Get a value from $_POST / $_GET. If unavailable, take a default value.

setCookieLanguage()

Change language in cookie while clicking on a flag.

switchLanguage()

Set cookie id_lang.

setCurrency()

Set cookie currency from POST or default currency.

displayPrice($price, $currency = NULL, $no_utf8 = false)

Return price with currency sign for a given product.

convertPrice($price, $currency = NULL, $to_currency = true)

Return price converted.

dateFormat($params, &$smarty)

Display date regarding to language preferences.

displayDate($date, $id_lang, $full = false, $separator = '-')

Display date regarding to language preferences.

safeOutput($string, $html = false)

Sanitize a string.

deleteDirectory($dirname, $delete_self = true)

Delete directory and subdirectories.

displayError($string = 'Fatal error', $htmlentities = true)

Display an error according to an error code.

dieObject($object, $kill = true)

Display an error with detailed object.

isSubmit($submit)

Check if submit has been posted.

getMetaTags($id_lang, $page_name)

Get meta tages for a given page.

getHomeMetaTags($id_lang, $page_name)

Get meta tags for a given page.

encrypt($passwd)

Encrypt password.

getToken($page = true)

Get token to prevent CSRF.

getAdminToken($string)

Encrypt password.

getPath($id_category, $path = '', $linkOntheLastItem = false, $categoryType = 'products')

Get the user's journey.

link_rewrite($str, $utf8_decode = false)

Return the friendly url from the provided string.

str2url($str)

Return a friendly url made from the provided string. If the mbstring library is available, the output is the same as the js function of the same name.

truncate($str, $maxLen, $suffix = '...')

Truncate strings.

dateYears()

Generate date form.

dateDays()

dateMonths()

dateFrom($date)

dateTo($date)

toCamelCase($str, $capitaliseFirstChar = false)

Translates a string with underscores into camel case (e.g. first_name -> firstName).

addJS($js_uri)

load a javascript file in the header.

addCSS($css_uri, $css_media_type = 'all')

allows you to add stylesheet at any time.

cccCss()

Combine Compress and Cache CSS (ccc) calls.

cccJS()

Combine Compress and Cache (ccc) JS calls.

jsonDecode($json, $assoc = false)

Convert json string to php array / object.

ZipTest($fromFile)

Try to open a zip file in order to check if it's valid.

ZipExtract($fromFile, $toDir)

Extract a zip file to the given directory.

getProductsOrder($type, $value = null)

Get products order field name for queries.

convertBytes($value)

Convert a shorthand byte value from a PHP configuration directive to an integer value.

AdminTabCore (AdminTab.php)

Method name and parameters

Description

l($string, $class = 'AdminTab', $addslashes = FALSE, $htmlentities = TRUE)

use translations files to replace english expression.

validateRules($className = false)

Manage page display (form, list...).

_childValidation()

Overload this method for custom checking in validateRules() .

ajaxPreProcess()

a method called in ajax-tab.php before displayConf().

ajaxProcess()

the default handle method for request with ajax-tab.php.

postImage($id)

Overload this method for custom checking in postProcess()'s object creation/update routine.

copyFromPost(&$object, $table)

Copy datas from $_POST to object.

displayWarning($warn)

Display a warning message.

getList($id_lang, $orderBy = NULL, $orderWay = NULL, $start = 0, $limit = NULL)

Get the current objects' list form the database.

displayImage($id, $image, $size, $id_image = NULL, $token = NULL, $disableCache = false)

Display image aside object form.

displayListHeader($token = NULL)

Display list header (filtering, pagination and column names).

displayTop()

Overload this method for custom display in displayList().

displayFlags($languages, $defaultLanguage, $ids, $id, $return = false)

Display flags in forms for translations.

PDFCode (PDF.php)

Method name and parameters

Description

Header()

Invoice header.

Footer()

Invoice footer.

ConfigurationCore (Configuration.php)

Method name and parameters

Description

getTranslationsFieldsChild()

Check then return multilingual fields for database interaction.

deleteByName($key)

Delete a configuration key in database (with or without language management).

get($key, $id_lang = NULL)

Get a single configuration value (in one language only).

set($key, $values)

Set TEMPORARY a single configuration value (in one language only).

getInt($key)

Get a single configuration value (in multiple languages).

getMultiple($keys, $id_lang = NULL)

Get several configuration values (in one language only).

getMultipleInt($keys)

Get several configuration values (in multiple languages).

updateValue($key, $values, $html = false)

Update configuration key and value into database (automatically insert if key does not exist).

CookieCore (Cookie.php)

Method name and parameters

Description

setExpire($expire)

Set expiration date.

__get($key)

Magic method wich return cookie data from _content array.

__isset($key)

Magic method which check if key exists in the cookie.

__set($key, $value)

Magic method wich add data into _content array.

__unset($key)

Magic method wich delete data into _content array.

isLogged($withGuest = false)

Check customer informations saved into cookie and return customer validity.

isLoggedBack()

Check employee informations saved into cookie and return employee validity.

logout()

Delete cookie.

mylogout()

Soft logout, delete everything links to the customer but leave there affiliate's informations.

update($nullValues = false)

Get cookie content.

write()

Save cookie with setcookie().

getFamily($origin)

Get a family of variables (e.g. "filter_").

DbCore (Db.php)

Method name and parameters

Description

getInstance($master = 1)

Get Db object instance (Singleton).

autoExecute($table, $values, $type, $where = false, $limit = false, $use_cache = 1)

Filter SQL query within a blacklist.

autoExecuteWithNullValues($table, $values, $type, $where = false, $limit = false)

Filter SQL query within a blacklist.

pSQL($string, $htmlOK = false)

Sanitize data which will be injected into SQL query.

nl2br2($string)

Convert \n and \r\n and \r to <br />.

LinkCore (Link.php)

Method name and parameters

Description

getProductDeletePictureLink($product, $id_picture)

This function returns a link to delete a customization picture file.

getProductLink($id_product, $alias = NULL, $category = NULL, $ean13 = NULL, $id_lang = NULL)

Return the correct link for product/category/supplier/manufacturer.

getCategoryLink($id_category, $alias = NULL, $id_lang = NULL)

getCMSCategoryLink($id_category, $alias = NULL, $id_lang = NULL)

getCMSLink($cms, $alias = null, $ssl = false, $id_lang = NULL)

getSupplierLink($id_supplier, $alias = NULL, $id_lang = NULL)

getManufacturerLink($id_manufacturer, $alias = NULL, $id_lang = NULL)

getCustomLink($id_custom, $page, $prefix = '~', $alias = NULL, $id_lang = NULL)

getImageLink($name, $ids, $type = NULL)

Returns a link to a product image for display. Note: the new image filesystem stores product images in subdirectories of img/p/.

getMediaLink($filepath)

preloadPageLinks()

getPageLink($filename, $ssl = false, $id_lang = NULL)

getCatImageLink($name, $id_category, $type = null)

getLanguageLink($id_lang)

Create link after language change, for the change language block.

goPage($url, $p)

getPaginationLink($type, $id_object, $nb = false, $sort = false, $pagination = false, $array = false)

addSortDetails($url, $orderby, $orderway)

getLangLink($id_lang = NULL)

MailCore (Mail.php)

Method name and parameters

Description

Send($id_lang, $template, $subject, $templateVars, $to, $toName = NULL, $from = NULL, $fromName = NULL, $fileAttachment = NULL, $modeSMTP = NULL, $templatePath = PS_MAIL_DIR, $die = false)

sendMailTest($smtpChecked, $smtpServer, $content, $subject, $type, $to, $from, $smtpLogin, $smtpPassword, $smtpPort = 25, $smtpEncryption)

l($string, $id_lang = null)

This method is used to get the translation for email Object. For an object is forbidden to use htmlentities, we have to return a sentence with accents.

FrontControllerCore (FrontController.php)

Method name and parameters

Description

preProcess()

Overload this method for custom display. This runs between the initialization of the page and the display of the header.

process()

Overload this method for custom display. This runs between the display of the header and the display of the content.

Return the set protocol according to configuration (http).

ObjectModelCore (ObjectModel.php)
ToolsCore (Tools.php)
AdminTabCore (AdminTab.php)
PDFCode (PDF.php)
ConfigurationCore (Configuration.php)
CookieCore (Cookie.php)
DbCore (Db.php)
LinkCore (Link.php)
MailCore (Mail.php)
FrontControllerCore (FrontController.php)
Modules, Override, Web Service
Modules, Classes and Controller Override
Public and overloadable methods
s