PrestaShop v1.6 Architecture

PrestaShop uses Model-View-Controller (MVC) for its software architecture, which is often used in web applications where webpages are dynamically generated. MVC isolates application logic from the input and presentation, so that they can be separately developed, tested and maintained.

A view provides the user interface presented to the customer in the browser. A controller receives input from the browser, decides what to do with it and then passes information to models that carry out specific tasks.

In PrestaShop 1.6, the models are in the classes directory, the views are in the themes directory and the controllers are in the controllers directory. The files in the root directory are the public interface used to call the controllers.

Everything passes through index.php in the root directory to improve sharing of code and make processing friendly URLs easier. There are also index.php files in all subdirectories of PrestaShop, but these are used only to prevent the contents of the directories from being displayed in browsers. Some subdirectories have an .htaccess file too to allow or block access to individual files.

All the models, views and controllers have a warning at the top of them to not modify the file if the website will be upgraded to a new version of PrestaShop in the future. This is because PrestaShop allows these files to be overridden.

Classes and controllers are overridden using the override directory. By overriding classes and controllers instead of modifying them, they can be safely overwritten by a new version of PrestaShop in the future without losing any changes that were made.

PrestaShop's modules also have the same warning, since they can be overridden in a theme by mirroring the module's directory inside the theme, e.g. themes/themename/modules/blockuserinfo/blockuserinfo.tpl.

Models

The models in the classes directory of PrestaShop are all PHP classes that extend the ObjectModel class. This class gives the models a unique ID and a table name and identifier to link them to a row in the database.

For example, in the Address model, the ID is a positive integer, the table name is address and the table identifier is id_address. The ObjectModel class also defines the model's field sizes and the functions in the Validate class that are used to validate fields.

It also links the model to the webservice feature and provides a cache. The model class names all end in Core so they can be overridden in the override/classes directory. Here is a description of each PrestaShop model:

Model FilenameDescription
order/Order.phpCustomer order information.
order/OrderDetail.phpCustomer order products.
order/OrderDiscount.php(deprecated) Customer order vouchers.
order/OrderHistory.phpCustomer order status history.
order/OrderMessage.phpPrefilled order messages that employees can use.
order/OrderReturn.phpMerchandise returns.
order/OrderReturnState.phpMerchandise return statuses.
order/OrderSlip.phpCredit slips.
order/OrderState.phpOrder statuses.
range/RangePrice.phpCarrier price ranges.
range/RangeWeight.phpCarrier weight.
shop/Shop.phpShops (multistore).
shop/ShopGroup.phpShop groups (multistore).
shop/ShopURL.phpShop URLs (multistore).
stock/Stock.phpProducts kept in warehouses (advanced stock management).
stock/StockAvailable.phpQuantity of products kept in warehouses (advanced stock management).
stock/StockMvt.phpStock movements (advanced stock management).
stock/StockMvtReason.phpStock movement reasons (advanced stock management).
stock/StockMvtWs.phpStock movements through Webservice (advanced stock management).
stock/SupplyOrder.phpSupply orders (advanced stock management).
stock/SupplyOrderDetail.phpSupply order products (advanced stock management).
stock/SupplyOrderHistory.phpSupply order status history (advanced stock management).
stock/SupplyOrderReceiptHistory.phpSupply order receipt history (advanced stock management).
stock/SupplyOrderState.phpSupply order statuses (advanced stock management).
stock/Warehouse.phpWarehouses
stock/WarehouseProductLocation.phpWarehouse product location reference codes.
tax/Tax.phpTax names and rates.
tax/TaxRules.phpSpecific tax rules.
tax/TaxRulesGroup.phpGroups of the tax rules.
webservice/WebserviceKey.phpWebservice account keys.
Address.php Customer, manufacturer and supplier addresses.
AddressFormat.phpAddress format for each country.
Alias.phpAliases used to redirect typos in the search box in the Front Office.
Attachment.phpFile attachments that are added to products.
Attribute.phpProduct attributes that display as dropdowns on the product page.
AttributeGroup.phpProduct attribute groups that display as labels for the dropdowns.
Carrier.phpCarriers used to ship products to customers.
Cart.phpCustomer carts including those that didn't result in an order.
CartRule.phpCustomer cart rules including reductions, free shipping and gifts.
Category.phpProduct categories used to organise products.
CMS.phpCMS pages used to display information.
CMSCategory.phpCategories used to organise CMS pages.
CMSRole.phpUsed by Advanced EU Compliance module to link CMS pages to legal roles.
Combination.phpCombinations of product attributes and their prices.
CompareProduct.phpCustomer comparisons of products.
Configuration.phpNon-translated configuration settings.
ConfigurationKPI.phpKey Performance Indicators (KPIs) displayed on Back Office tabs.
Connection.phpStatistics about page visits.
ConnectionsSource.phpStatistics about the source of page visits.
Contact.phpDepartments that can be selected on the contact form.
Country.phpCountries used in addresses.
County.php(deprecated) Counties used in addresses.
Currency.phpCurrencies used in prices.
Customer.phpCustomers who have registered.
CustomerMessage.phpIndividual messages sent between customers and employees.
CustomerThread.phpThreads of messages sent between customers and employees.
Customization.phpProduct customization data associated with customer carts.
CustomizationField.phpImage and text customization fields displayed on product pages.
DateRange.phpDate ranges used in page visits.
Delivery.phpLinks between carriers, zones and ranges.
Discount.php(deprecated) Vouchers that can be used by customers.
Employee.phpEmployees who can log in to the Back Office.
Feature.phpProduct feature labels on the product page.
FeatureValue.phpProduct feature values on the product page.
Group.phpCustomer groups and display methods.
GroupReduction.phpCustomer group reductions.
Guest.phpCustomers who haven't registered.
Hook.phpHooks where modules can be placed.
Image.phpProduct images.
ImageType.phpImage thumbnail sizes.
Language.phpLanguages used on the website.
Mail.phpLog entries of e-mails sent and received.
Manufacturer.phpProduct manufacturers.
Message.phpCustomer messages sent from the order history page.
Meta.phpMeta-information of PrestaShop's pages.
Pack.phpProduct packs (extends Product class).
Page.phpPrestaShop's non-CMS pages.
PaymentCC.php(deprecated) Order credit card information.
PrestaShopLogger.phpLog entries for employee log-ins, modifications and errors.
Product.phpProduct information.
ProductDownload.phpDownloadable products.
ProductSupplier.phpSupplier product reference codes and prices.
Profile.phpProfiles used to restrict employee access.
QuickAccess.phpShortcuts in the dropdown at the top of the Back Office.
RangePrice.phpCarrier price ranges.
RangeWeight.phpCarrier weight ranges.
Referrer.phpAffiliate program data.
RequestSql.phpSaved queries from the SQL Manager tab.
Risk.phpBusiness-to-Business (B2B) risk ratings.
Scene.phpImage maps that link products to banners.
SearchEngine.phpSearch engines tracked when guests visit.
SpecificPrice.phpSpecific prices including quantity discounts for a product.
SpecificPriceRule.phpSpecific price rules applied to multiple products.
State.phpStates used in addresses.
Store.phpStores used in the store locator module.
StockMvt.phpStock movements used to track employees' changes.
StockMvtReason.phpStock movement reasons.
SubDomain.phpSubdomains used by PrestaShop's cookie.
Supplier.phpProduct suppliers.
Tab.phpBack Office tabs and positions.
Tag.phpProduct tags used by the tag cloud module.
Theme.phpTheme settings.
Zone.phpZones used by the carriers.

Here's a description of the other PrestaShop classes that do not store data in the database:

Class FilenameDescription
cache/Cache.phpProvides basic caching functionality.
cache/CacheApc.phpPerforms APC caching.
cache/CacheFS.phpPerforms File System caching.
cache/CacheMemcache.phpPerforms Memcache caching.
cache/CacheMemcached.phpPerforms Memcached caching.
cache/CacheXcache.phpPerforms Xcache caching.
controller/AdminController.phpProvides basic Back Office tab functionality.
controller/Controller.phpProvides basic controller functionality such as adding CSS and JavaScript.
controller/FrontController.phpInitialises Smarty variables and other basic controller code.
controller/ModuleAdminController.phpUsed by modules to create a Back Office tab.
controller/ModuleFrontController.phpUsed by modules to create a Front Office page.
db/Db.phpProvides basic database functionality.
db/DbMySQLi.phpConnects to a MySQL database using MySQLi.
db/DbPDO.phpConnects to a MySQL database using PDO.
db/DbQuery.phpGenerates an SQL query.
db/MySQL.phpProvides access to a MySQL database.
exception/PrestaShopDatabaseException.phpDisplays a MySQL database error message.
exception/PrestaShopException.phpDisplays a 500 Internal Server Error and backtrace for debugging.
exception/PrestaShopModuleException.phpDisplays a module error.
exception/PrestaShopPaymentException.phpDisplays a payment error.
helper/Helper.phpProvides basic helper functionality.
helper/HelperCalendar.phpDisplays a calendar in the Back Office.
helper/HelperForm.phpDisplays a form in the Back Office.
helper/HelperImageUploader.phpValidates image uploads.
helper/HelperKpi.phpDisplays a group of Key Performance Indicators (KPIs).
helper/HelperKpiRow.phpDisplays a Key Performance Indicator (KPI).
helper/HelperList.phpDisplays a list of objects in the Back Office.
helper/HelperOptions.phpDisplays a configuration page.
helper/HelperShop.phpDisplays a dropdown of shop contexts in the Back Office.
helper/HelperTreeCategories.phpDisplays a tree of categories in the Back Office.
helper/HelperTreeShops.phpDisplays a tree of shops in the Back Office.
helper/HelperUploader.phpDisplays a file uploader in the Back Office.
helper/HelperView.phpDisplays an individual item in the Back Office.
log/AbstractLogger.phpProvides basic logging functionality.
log/FileLogger.phpSaves logs to a file.
module/CarrierModule.phpProvides basic shipping module functionality.
module/ImportModule.phpProvides basic shop import functionality.
module/Module.phpProvides basic module functionality.
module/ModuleGraph.phpProvides module graph functionality.
module/ModuleGraphEngine.phpProvides module graph engine functionality.
module/ModuleGrid.phpProvides module grid functionality.
module/ModuleGridEngine.phpProvides module grid engine functionality.
pdf/HTMLTemplate.phpSets the data for the header and footer of PDF files.
pdf/HTMLTemplateDeliverySlip.phpSets the data and filename of the delivery slip.
pdf/HTMLTemplateInvoice.phpSets the data and filename of the invoice.
pdf/HTMLTemplateOrderReturn.phpSets the data and filename of the merchandise return.
pdf/HTMLTemplateOrderSlip.phpSets the data and filename of the credit slip.
pdf/HTMLTemplateSupplyOrderForm.phpSets the data and filename of the supply order form.
pdf/PDF.phpDesigns the PDF files using the HTML templates.
pdf/PDFGenerator.phpGenerates PDF files using TCPDF.
stock/StockManager.phpThe default stock manager (advanced stock management).
stock/StockManagerFactory.phpGets a stock manager (advanced stock management).
stock/StockManagerInterface.phpThe interface for managing stock (advanced stock management).
stock/StockManagerModule.phpEnables a module to manage stock (advanced stock management).
tax/AverageTaxOfProductsTaxCalculator.phpCalculates the average tax of products in an order.
tax/TaxCalculator.phpCalculates taxes.
tax/TaxManagerFactory.phpGets a tax manager.
tax/TaxManagerInterface.phpThe interface for managing taxes.
tax/TaxManagerModule.phpEnables a module to manage tax.
tax/TaxRulesTaxManager.phpThe default tax manager.
tree/ITreeToolbar.phpThe interface for tree toolbars in the Back Office.
tree/ITreeToolbarButton.phpThe interface for tree toolbar buttons in the Back Office.
tree/Tree.phpCreates a tree in the Back Office.
tree/TreeToolbar.phpCreates a tree toolbar in the Back Office.
tree/TreeToolbarButton.phpCreates a tree toolbar button in the Back Office.
tree/TreeToolbarLink.phpCreates a tree toolbar link in the Back Office.
tree/TreeToolbarSearch.phpCreates a tree toolbar search box in the Back Office.
tree/TreeToolbarSearchCategories.phpCreates a tree toolbar search box for categories in the Back Office.
webservice/WebserviceException.phpDisplays a Webservice error.
webservice/WebserviceOutputBuilder.phpBuilds Webservice output.
webservice/WebserviceOutputInterface.phpThe interface for displaying Webservice output.
webservice/WebserviceOutputJSON.phpDisplays Webservice output in JSON format.
webservice/WebserviceOutputXML.phpDisplays Webservice output in XML format.
webservice/WebserviceRequest.phpProcesses a Webservice request.
webservice/WebserviceSpecificManagementImages.phpManages images through Webservice.
webservice/WebserviceSpecificManagementInterface.phpThe interface for managing specific data.
webservice/WebserviceSpecificManagementSearch.phpManages specific queries on the data through the Webservice.
AdminTab.php(deprecated) Provides basic Back Office tab functionality.
Blowfish.phpEncrypts the PrestaShop cookie with Blowfish.
Chart.phpCreates charts.
ConfigurationTest.phpTests whether the server configuration is compatible with PrestaShop.
Context.phpUsed to get all the data related to the current customer or employee.
ControllerFactory.php(deprecated) Gets a controller or its override.
Cookie.phpReads and writes PrestaShop's cookie.
CSV.phpGenerates a CSV file.
Dispatcher.phpCalls a controller.
FileUploader.phpPerforms file uploads.
ImageManager.phpGenerates image thumbnails.
Link.phpGets links to products, categories, CMS pages, etc.
LocalizationPack.phpInstalls localisation packs.
Mail.phpSends emails.
Media.phpManages CSS, JavaScript and minification.
Notification.phpHandles notifications in the Back Office.
PaymentModule.phpProvides basic payment module functionality.
PrestaShopAutoload.phpAutomatically loads classes when needed.
PrestaShopBackup.phpManages PrestaShop backups.
PrestaShopCollection.phpManages SQL queries and results.
ProductSale.phpManages product sale numbers.
Rijndael.phpEncrypts PrestaShop's cookie using mcrypt.
Search.phpPerforms searchs on products.
SmartyCacheResourceMysql.phpTracks compiled and cached Smarty templates.
SmartyCustom.phpManages Smarty caching and flushing.
Tools.phpContains many useful conversion and sanitization functions.
Translate.phpGets translations.
Upgrader.phpCompares PrestaShop version and files for changes.
Uploader.phpHandles file uploads.
Validate.phpValidates data.

Here's a description of the ObjectModel members:

Member NameDescription
$cache_objectsWhether the objects can be cached.
$dbThe database manager.
$defThe current object's definition.
$definitionDefines the default table, identifier and fields of objects.
$fieldsRequired(deprecated) The required fields.
$fieldsRequiredDatabaseThe required fields that have been overridden by an employee.
$fieldsSize(deprecated) The maximum size of each non-translatable field.
$fieldsSizeLang(deprecated) The maximum size of each translatable field.
$fieldsValidate(deprecated) Array of validation functions that check non-translatable fields.
$fieldsValidateLang(deprecated) Array of validation functions that check translatable fields.
$force_idWhether to use the specified ID when adding the object.
$get_shop_from_contextWhether to get the shop from the current context.
$idThe integer ID of the object, e.g. 1
$id_langThe language ID used to select translations of the object.
$id_shopThe shop ID used to choose which shop to get data from.
$id_shop_listThe IDs of every shop the object is associated with.
$identifier(deprecated) The name of the ID of the object, e.g. id_address
$image_dirThe image directory used when deleting objects.
$image_formatThe image extension used when deleting objects.
$loaded_classesContains a list of loaded classes.
$table(deprecated) The main table used by the object.
$tables(deprecated) All the tables used by the object.
$update_fieldsUsed to update specific fields (or null for all fields).
$webserviceParametersThe webservice parameters for the object.

Here's a description of the ObjectModel functions:

Function NameDescription
__construct()Loads an object with the specified ID, language and shop.
add()Adds the current object to the database.
addFieldsRequiredDatabase()Adds the fields marked as required to the database.
associateTo()Associates the object with the specified shops.
cacheFieldsRequiredDatabase()Caches the fields marked as required.
clearCache()Used to clear the cache whenever an object is modified.
delete()Deletes the current object from the database.
deleteImage()Deletes images associated with the object.
deleteSelection()Deletes the specified list of objects from the database.
disableCache()Disables caching of objects.
displayFieldName()Gets the unique name of a field.
duplicateObject()Creates a duplicate of the object, its translations and shops.
duplicateShops()Copies the object's shop associations to another object.
enableCache()Enabls caching of the object.
existsInDatabase()Checks whether the object's ID exists in the database.
formatFields()Formats the fields based on their specified types.
formatValue()Formats a specific value.
getAssociatedShops()Gets all shops associated with the object.
getDefinition()Gets the object's definition.
getFieldByLang()Gets the value of the field for the specified language.
getFields()Gets the non-translatable fields for the object.
getFieldsShop()Gets fields for the current shop.
getFieldsRequiredDatabase()Gets the fields marked as required from the database.
getTranslationFields()(deprecated) Gets the translatable fields for the object.
getValidationRules()Gets the validation rules for the object.
getWebserviceObjectList()Gets a list of all webservice objects.
getWebserviceParameters()Gets the webservice parameters for the object.
hasMultishopEntries()Checks whether the object is in multiple shops.
hydrate()Fills the object with the specified data.
hydrateCollection()Fills a collection of objects with the specified data.
isAssociatedToShop()Checks whether the object is associated with the specified shop.
isCurrentlyUsed()Checks whether the object exists and is active.
isLangMultishop()Checks whether the object has shop-specific translations.
isMultishop()Checks whether the object is shop-specific.
isMultiShopField()Checks whether a field is shop-specific.
makeTranslationFields()(deprecated) Creates translation fields for the specified language.
save()Saves the object, adding it or updating it as necessary.
setDefinitionRetrocompatibility()Creates a definition using the deprecated fields.
setFieldsToUpdate()Sets which fields to update when the update() function is called.
toggleStatus()Toggles whether the object is visible on the website.
update()Updates the current object in the database.
updateMultishopTable()Updates the shop-specific data.
validateControler()(deprecated) Checks whether required fields have valid data.
validateController()Checks whether required fields have valid data.
validateField()Validates a single field value.
validateFields()Checks whether required non-translatable fields have valid data.
validateFieldsLang()Checks whether required translatable fields have valid data.
validateFieldsRequiredDatabase()Validates all fields marked as required in the database.

Here's a description of the validation functions:

Function NameDescription
isAbsoluteUrl()Is an absolute URL (e.g., http://www.domain.com).
isAddress()Is an address line (^!<>?=+@{}_$% not allowed).
isAnything()Accepts anything without doing any validation.
isApe()Is a valid APE code (3 or 4 numbers followed by a letter).
isArrayWithIds()Is an array containing only positive integers.
isBirthDate()Is empty date or a date in yyyy-mm-dd format at least 9 years ago.
isBool()Is a Boolean value 0 or 1.
isBool_Id()(deprecated) Is a Boolean id (0 or 1 followed by an underscore, then digits).
isBoolId()Is a Boolean id (0 or 1 followed by an underscore, then digits).
isCarrierName()Is a valid carrier name (^<>;=#{} not allowed).
isCatalogName()Is a catalog name (^<>;=#{} not allowed).
isCityName()Is a city name (^!<>;?=+@#"°{}_$% not allowed).
isCleanHtml()Is HTML without script tags or events.
isColor()Is a colour keyword or hexadecimal code.
isConfigName()Is a configuration key (alphanumeric and hypens).
isControllerName()Is a controller name (non-Unicode alphanumeric, hyphens and underscores).
isCookie()Is an instance of the Cookie class.
isCoordinate()Is a coordinate (up to 6 digits, a period, then up to 6 digits).
isCountryName()Is a country name (lowercase letters, spaces and hyphens).
isDate()Is a date in yyyy-mm-dd format.
isDateFormat()Is a valid date in yyyy-mm-dd format.
isDirName()Is a directory name (alphanumeric, hyphens, underscores and periods).
isDiscountName()Is a valid voucher code (3-32 characters except ^!<>,;?=+()@"°{}_$%:).
isDistanceUnit()Is a distance unit (up to 2 letters).
isDniLite()Is a DNI number (1 to 13 alphanumeric with hyphens and periods).
isEan13()Is a 13-digit EAN13 code.
isEmail()Is an email of the form username@domain.tld.
isFileName()Is a valid filename (alphanumeric, hyphens, underscores and periods).
isFloat()Is a valid float value.
isGenericName()Is a generic name (^<>;=#{} not allowed).
isHookName()Is a valid hook name (lowercase alphanumeric and hyphens).
isImageSize()Is an image size (up to 4 digits).
isImageTypeName()Is a valid image type name (lowercase alphanumeric, spaces and hyphens).
isImageSize()Is an image size (an integer with a length 1 and 4 numbers).
isInt()Is an integer.
isIp2Long()Is a valid IP address.
isLabel()Is a customisation field label (^{}<> allowed).
isLangIsoCode()Is a language iso code (2 or 3 alphanumeric).
isLanguageCode()Is a language code (2 letters, a hyphen and another 2 letters).
isLanguageFileName()Is a language filename (2 or 3 alphanumeric followed by .gzip or .tar.gz).
isLanguageIsoCode()Is a valid language ISO code (2 or 3 lowercase letters).
isLinkRewrite()Is a rewritten link (lowercase alphanumeric, hypens and underscores).
isLoadedObject()Is a variable is an object and has a valid ID.
isLocalizationPackSelection()Is "states", "taxes", "currencies", "languages" or "units".
isMailName()Is a valid mail name (^<>;=#{} not allowed).
isMailSubject()Is a valid mail subject (^<>{} not allowed).
isMessage()Is a message (<>{} not allowed except <br />).
isMd5()Is a valid MD5 hash.
isModuleName()Is a valid module name (lowercase alphanumeric and hyphens).
isModuleUrl()Is a valid URL to a zip, tgz or tar.gz file.
isMySQLEngine()Is a MySQL Engine (InnoDB or MySAM)
isName()Is a valid name (^0-9!<>,;?=+()@#"°{}_$%: not allowed).
isNegativePrice()Is a positive or negative price (an optional hyphen, up to 10 digits, a period, then up to 9 digits).
isNumericIsoCode()Is a numeric ISO code (2 or 3 digits).
isOptFloat()Is an empty field or valid float value.
isOrderInvoiceNumber()Is an order invoice number (the configured invoice prefix followed by numbers).
isOrderWay()Is a valid order way 'ASC', 'DESC', 'asc' or 'desc'.
isOrderBy()Is a valid order (lowercase alphanumeric, hyphens and underscores).
isPasswd()Is a customer password (5-32 alphanumeric and (). -!@#$%^&*).
isPasswdAdmin()Is an employee password (8-32 alphanumeric and (). -!@#$%^&*).
isPercentage()Is a percentage (a decimal number between 0 and 100).
isPhpDateFormat()Is a PHP date format (anything but < and >).
isPhoneNumber()Is a phone number (digits, hyphens, spaces, parentheses and periods).
isPostCode()Is a postcode (alphanumeric and hyphens).
isPrestaShopVersion()Is a PrestaShop version (0 or 1 following by 3 one-or-two-digit numbers separated by periods).
isPrice()Is a valid price (up to 10 digits, a period, then up to 9 digits).
isPriceDisplayMethod()Is a price display method (PS_TAX_EXC or PS_TAX_INC).
isProductVisibility()Is a product visibility (both, catalog, search or none)
isReductionType()Is a reduction type "amount" or "percentage".
isReference()Is a reference (^<>;={} not allowed).
isRoutePattern()Is a friendly URL route pattern.
isSceneZones()Is an array of image map zones (must have x1, y1, width, height and id_product keys with integer values).
isSerializedArray()Is a serialised array.
isSha1()Is a valid SHA1 hash.
isSiret()Is a SIRET code.
isSortDirection()Is a sort direction 'ASC' or 'DESC'.
isStateIsoCode()Is a valid state ISO code (up to 4 lowercase alphanumeric).
isStockManagement()Is a type of stock management (WA, FIFO or LIFO).
isString()Is a string.
isSubDomainName()Is a subdomain name.
isTablePrefix()Is a table prefix (alphanumeric and underscore).
isTableOrIdentifier()Is a table name (lowercase alphanumeric, hyphens and underscores).
isTabName()Is a valid tab name (alphanumeric, hyphens and underscores).
isTagsList()Is a tags list (^!<>;?=+#"°{}_$% not allowed).
isTplName()Is a valid template name (lowercase alphanumeric and hyphens).
isTrackingNumber()Is a shipping tracking number.
isUnixName()Is a UNIX filename (non-Unicode alphanumeric, hyphens, underscores, backslashes and periods).
isUnsignedFloat()Is a valid positive float value.
isUnsignedId()Is a positive integer.
isUnsignedInt()Is a positive integer.
isUrl()Is a valid URL.
isUrlOrEmpty()Is a valid URL or an empty string.
isUpc()Is a 12-digit UPC code.
isValidSearch()Is a valid search (up to 64 characters except ^<>;=#{}).
isValuesList()(deprecated) Is a MySQL query values list.
isVoucherDescription()Is a voucher description (<>{} not allowed except <br />).
isWeightUnit()Is a weight unit (up to 3 letters).
isZipCodeFormat()Is a zip code format (using uppercase letters N, L, C, spaces and hyphens).

Here's a list of useful static functions available in the Tools class:

Function NameDescription
addCSS(deprecated) Adds a CSS file to by combined, compressed and cached.
addJS(deprecated) Adds a JavaScript file to be combined, compressed and cached.
addonsRequestMakes a request to the PrestaShop Addons website.
alignVersionNumberAligns two version numbers so they are easier to compare.
apacheModExistsChecks whether the specified Apache module exists.
argvToGETAdds the specified arguments to the query string.
array_replaceReplaces values in an array.
arrayReplaceRecursiveReplaces values in an array recursively.
arrayUniqueRemoves duplicate values from an array.
boolValCasts the value as a Boolean.
cccCss(deprecated) Combines, compresses and caches the specified CSS files.
cccJS(deprecated) Combines, compresses and caches the specified JavaScript files.
ceilfRounds up a float to the specified number of decimal places.
changeFileMTimeChanges the modification time of the specified file.
checkPhpVersionGets the PHP version.
chmodrRecursively changes the permissions of the specified file or directory.
cleanNonUnicodeSupportDeletes unicode from from regular expressions.
clearCacheClears the cached Smarty templates in the cache/smarty/cache directory.
clearCompileClears the compiled Smarty templates in the cache/smarty/compile directory.
clearSmartyCacheClears the compiled and cached Smarty templates.
clearXMLCacheClears the cached XML files in the config/xml directory except for the installed themes.
completeMetaTags(deprecated) Fills missing meta information with the default values.
convertBytesConverts a shorthand byte to an integer.
convertPriceConverts a price from one currency to another.
convertPriceFullConverts a price from one currency to another and then rounds it.
copyCopies a file or URL.
dDisplays an error message with a detailed object and stops execution.
dateDaysGets a day array with the numbers 1 to 31.
dateFormatFormats the specified date according to the current language's date format.
dateFromAdds 00:00:00 to the date if a time doesn't already exist.
dateMonthsGets a month array with January to December.
dateToAdds 23:59:59 to the date if a time doesn't already exist.
dateYearsGets a year array from the current year back to 1900.
debug_backtraceDisplays a stack trace for debugging.
deleteDirectoryDeletes a directory and its subdirectories.
deleteFileDeletes a file if it isn't in the excluded array.
dieObjectDisplays an error message with a detailed object.
dieOrLogDisplays an error message and/or logs it.
display404Error(deprecated) Displays the "Page not found" page.
displayAsDeprecatedDisplays a message that the called function is deprecated.
displayDateFormats the specified date according to the current language's date format.
displayErrorDisplays the specified error message.
displayFileAsDeprecatedDisplays a message that the called file is deprecated.
displayNumberChanges the thousands separator of a number according to the specified currency.
displayParameterAsDeprecatedDisplays a message that the specified parameter is deprecated.
displayPriceRounds and formats the price according to the specified currency.
displayPriceSmartyUsed to format the price from a Smarty template.
enableCacheEnables Smarty caching.
encryptEncrypts the specified password using the cookie key and MD5 hashes it.
encryptIVEncrypts data using the cookie IV and MD5 hashes it.
error_logWrites the specified object to the PHP error log.
fdDisplays the specified object in the Firebug console.
file_exists_cacheChecks whether the specified file exists with a cache.
file_exists_no_cacheChecks whether the specified file exists without the cache.
file_get_contentsDownloads the content from the specified URL.
fileAttachmentGets information about file uploads.
floorfRounds down a float to the specified number of decimal places.
formatBytesShortens a number from 10,000 to 10k, for example.
generateHtaccessRegenerates the .htaccess file in PrestaShop's root.
generateIndexRegenerates cache/class_index.php.
getAdminTokenGets the security token for a Back Office tab.
getAdminTokenLiteGets the security token for the current employee.
getAdminTokenLiteSmartyGets the security token for the current employee from a Smarty template.
getAdminUrlMakes a URL valid for use in the Back Office.
getAllValuesGets all $_GET and $_POST variables in a single array.
getBrightnessGets the brightness of a hex colour code.
getBytesGets random bytes of the specified length.
getCountryGets the customer's country from their entered address or IP address.
getCurrentUrlProtocolPrefixGets either http:// or https://.
getDefaultIndexContentGenerates the content for an index.php file to block access to a directory.
getDescriptionCleanRemoves all HTML tags from the specified description.
getFullPathGet the breadcrumb bar for the specified category, product or CMS page.
getHomeMetaTags(deprecated) Gets the meta-information for a specified page.
getHttpHostGets the current host with http:// or https://.
getIssetChecks whether the specified key exists in $_POST or $_GET.
getMaxUploadSizeGets the maximum file upload size.
getMediaServerGets the media servers configured on the Advanced Parameters > Performance tab.
getMemoryLimitGets the memory limit as an octet.
getMetaTags(deprecated) Gets the meta-information for the current product, category, manufacturer, supplier, cms page or cms category.
getOctetsConverts 10k to 1024, for example.
getPathGets part of the breadcrumb bar.
getProductsOrderGets the order by or way used to sort products.
getProtocolGets either http:// or https:// based on the "Use SSL" setting.
getRemoteAddrGets the IP address of the customer.
getSafeModeStatusGets whether PHP safe mode is enabled.
getServerNameThe name of the current server.
getShopDomainGets the configured shop name when SSL is disabled.
getShopDomainSslGets the configured shop name when SSL is enabled.
getShopProtocolGets http:// or https:// based on whether SSL is enabled on the server.
getTokenGets the customer's secure token for the current page.
getUserBrowserGets the customer's web browser.
getUserPlatformGets the customer's operating system.
getValueGets the value from $_POST, $_GET or the specified default value.
hourGenerateConverts values like 23 59 59 to 23:59:59.
htmlentitiesDecodeUTF8Decodes HTML entities such as &lt; to <
htmlentitiesUTF8Encodes HTML entities such as < to &lt;
iconvConverts currency signs to HTML entities.
isCallableChecks whether a function is enabled and can be called.
isEmptyChecks whether a string is empty.
isPHPCLIChecks whether PHP CLI is used.
isSubmitChecks whether the specified form was submitted.
isX86_64archChecks whether the server is 64-bit.
jsonDecodeDecodes JSON as a data array.
jsonEncodeEncodes a data array as JSON.
link_rewriteConverts a string to a friendly URL.
math_roundRounds the number to the specified number of places using the specified rounding method.
minifyCSS(deprecated) Minifies CSS styles.
minifyHTML(deprecated) Minifies HTML content.
minifyHTMLprefCallback(deprecated) Used when minifying HTML.
modRewriteActiveChecks whether mod_rewrite is active on the server.
nl2brConverts new line characters to <br />
normalizeDirectoryNormalizes a directory.
orderbyPriceOrders an array of product IDs by product price.
pDisplays an error with a detailed object, but doesn't stop execution.
packJS(deprecated) Minifies JavaScript files.
packJSinHTML(deprecated) Minifies JavaScript within HTML code.
packJSinHTMLpregCallback(deprecated) Used when minifying JavaScript.
parserSQLParses an SQL query.
passwdGenGenerates a random password of the specified length.
pRegexpRemoves query strings and other characters from the end of URLs.
property_exists(deprecated) Checks whether a class has the specified property.
ps_roundRounds a number to the specified number of decimal places using the specified rounding method.
purifyHTMLPurifies HTML of unsafe code.
recurseCopyRecursively copies a directory.
redirectRedirects to a Front Office URL.
redirectAdminRedirects to a Back Office URL.
redirectLinkRedirects a URL that already includes the base URI.
replaceAccentedCharsRemoves accents from characters.
replaceByAbsoluteURLReplaces relative URLs in with absolute URLs.
restoreCacheSettingsRestores the cache settings.
round_helperUsed when rounding numbers.
rtrimStringDeletes the first instance of a string started from the end.
safeDefineDefines a constant if it isn't already defined.
safeOutputConverts HTML entities and optionally strips tags.
safePostVarsConverts HTML entities in $_POST.
scandirGets a list of all files in a directory.
secureReferrerMakes the referrer URL secure.
setCookieLanguageChanges the customer's language.
setCurrencyChanges the customer's currency.
simplexml_load_fileLoads an XML file.
spreadAmountSpreads an amount over multiple lines.
str_replace_onceReplaces the first instance of a string in another string.
str2urlConverts a string to a friendly URL.
stripslashesUnquotes backslashes in a string.
strlenGets the number of numbers in a string.
strposGets the position of the first instance of a string in another string.
strReplaceFirstReplaces the first instance of a string in another string.
strrposGets the position of the last instance of a string in another string.
strtolowerMakes all letters in a string lowercase.
strtoupperMakes all letters in a string uppercase.
substrGets part of a string.
switchLanguageChanges the customer's language.
toCamelCaseConverts a string to camel case (first_name to firstName).
toUnderscoreCaseConverts a string to underscore case (firstName to first_name).
truncateTruncates a string to the specified number of characters and adds a suffix.
truncateStringTruncates a string to the specified number of characters.
ucfirstMakes the first letter uppercase.
ucwordsMakes the first letter of each word uppercase.
unSerializeUnserializes a string.
urlAdds a query string variable to a URL.
usingSecureModeChecks if the current page is using SSL.
version_compareCompares version numbers.
waitUntilFileIsModifiedWaits for a file to be modified for the specified number of seconds.
ZipExtractExtracts a ZIP file to the specified directory.
ZipTestTests whether a ZIP file is valid.

Views

PrestaShop uses Smarty templating for its views, which supplements HTML with a flexible syntax to add variables, if statements, loops and other PHP code to the view. Here is a description of PrestaShop's default theme templates:

View FilenameDescription
404.tplThe "Page not found" page.
address.tplThe address form.
addresses.tplLists customer addresses.
authentication.tplThe login and registration forms.
best-sales.tplLists the best-selling products.
breadcrumb.tplThe breadcrumb bar at the top of the centre column.
category-cms-tree.tplUsed by sitemap.php to list CMS pages on the sitemap.
category-count.tplDisplays the number of products in the current category.
category-tree-branch.tplUsed by sitemap.php to list subcategories on the sitemap.
category.tplLists a category's subcategories and products.
cms.tplDisplays a CMS page.
contact-form.tplThe customer service contact form.
discount.tplLists vouchers available to a customer.
errors.tplDisplays error messages.
footer.tplThe footer at the bottom of the website.
global.tplAdds JavaScript to the footer of the page.
guest-tracking.tplThe guest order tracking form.
header.tplThe header at the top of the website.
history.tplLists a customer's orders.
identity.tplThe customer's personal information form.
index.tplThe center column on the homepage.
layout.tplThe main layout of the page.
maintenance.tplThe maintenance page when the shop is disabled.
manufacturer.tplLists the products of a manufacturer.
manufacturer-list.tplLists manufacturers.
my-account.tplThe account page of a customer.
new-products.tplLists new products.
order-address.tplUsed by order.php and order-opc.php for the address step.
order-address-advanced.tplUsed by the Advanced EU Compliance module for the address step.
order-address-multishipping.tplForm to ship products to multiple addresses.
order-address-multishipping-products.tplForm to choose products for multishipping.
order-address-product-line.tplDisplays a single product line on the multishipping form.
order-carrier.tplUsed by order.php and order-opc.php for the carrier step.
order-carrier-advanced.tplUsed by the Advanced EU Compliance module for the carrier step on five-step checkout.
order-carrier-opc-advanced.tplUsed by the Advanced EU Compliance module for the carrier step on one-page checkout.
order-confirmation.tplThe order confirmation page.
order-detail.tplUsed by guest-tracking.php and history.php for order details.
order-follow.tplLists a customer's merchandise returns.
order-opc.tplThe one-page checkout page.
order-opc-advanced.tplUsed by the Advanced EU Compliance module for one-page checkout.
order-opc-new-account.tplUsed by order-opc.php for the login and new account forms.
order-opc-new-account-advanced.tplUsed by the Advanced EU Compliance module for the new account forms.
order-payment.tplUsed by order-opc.php for the payment step.
order-payment-advanced.tplUsed by the Advanced EU Compliance module to display payment methods.
order-payment-classic.tplDisplays payment methods.
order-return.tplDisplays information about a merchandise return.
order-slip.tplLists a customer's credit clips.
order-steps.tplUsed by order.php to display the order steps.
pagination.tplThe page navigation at the bottom of the centre column.
password.tplThe lost password form.
prices-drop.tplLists discounted products.
product-compare.tplAdds product comparison checkboxes to the product listings.
product-list.tplLists products.
product-list-colors.tplDisplays a colour picker on product listings.
product-sort.tplThe "Sort by" form at the top of product listings.
product.tplInformation about a product.
products-comparison.tplThe product comparison page.
restricted-country.tplDisplays a message when a customer has been restricted by country.
scenes.tplUsed by category.php to display banners that link to products.
search.tplList the search results page.
shopping-cart.tplUsed by order.php and order-opc.php to display the cart summary.
shopping-cart-advanced.tplUsed by the Advanced EU Compliance module for the shopping cart.
shopping-cart-product-line.tplUsed by shopping-cart.tpl to display a product line in the cart summary.
sitemap.tplThe sitemap of the website.
store_infos.tplThe store opening hours.
stores.tplThe store information and Google map.
supplier-list.tplLists suppliers.
supplier.tplLists products from a supplier.

The following Smarty variables are accessible in all of the templates:

Smarty variableDescription
{$add_prod_display}Whether to display the "Add to cart" button on products with attributes.
{$b2b_enable}Whether business-to-business (B2B) mode is enabled.
{$base_dir}The absolute base URL starting with http://.
{$base_dir_ssl}The absolute base URL starting with https://.
{$base_uri}The relative base URI without any protocol.
{$cart}Used to access the customer's shopping cart.
{$cart_qties}The number of products in the customer's shopping cart.
{$content_dir}The content URL starting with http://.
{$content_only}Whether to load the page without the header and footer (for Fancybox popups).
{$come_from}The original URL if the customer was redirected.
{$compared_products}The customer's chosen products for comparison.
{$comparator_max_item}The maximum number of products that can be compared.
{$cookie}Used to access the customer's cookie.
{$css_dir}Absolute URL to the CSS directory css inside the current theme's directory.
{$currencies}Used to access all currencies.
{$currency}Used to access the customer's currency.
{$currencyBlank}Whether the customer's currency has a blank space after the sign.
{$currencyFormat}The customer's currency format.
{$currencyRate}The conversion rate of the customer's currency.
{$currencySign}The customer's currency sign.
{$customerName}(deprecated) The customer's first and last names.
{$display_tax_label}Whether to display tax included and excluded labels.
{$force_ssl}Whether all URLs should use https://.
{$hide_left_column}Whether the left column should be hidden.
{$hide_right_column}Whether the right column should be hidden.
{$id_currency_cookie}(deprecated) The ID of the customer's currency.
{$img_cat_dir}The absolute URL to the category image directory img/c in PrestaShop's root.
{$img_col_dir}The absolute URL to the attribute texture directory img/co in PrestaShop's root.
{$img_dir}The absolute URL to the image directory img directory inside the current theme.
{$img_lang_dir}The absolute URL to the language flag directory img/l in PrestaShop's root.
{$img_manu_dir}The absolute URL to the manufacturer image directory img/m in PrestaShop's root.
{$img_prod_dir}The absolute URL to the product image directory img/p in PrestaShop's root.
{$img_ps_dir}The absolute URL to the image directory img in PrestaShop's root.
{$img_ship_dir}The absolute URL to the carrier image directory img/s in PrestaShop's root.
{$img_store_dir}The absolute URL to the store image directory img/st
{$img_sup_dir}The absolute URL to the supplier image directory img/su in PrestaShop's root.
{$img_update_time}The time the shop logo was last updated.
{$is_guest}Whether the customer is a guest.
{$is_logged}Whether the customer is logged in.
{$js_dir}Absolute URL to the JavaScript directory js inside the current theme's directory.
{$lang_id}The ID of the customer's language (1).
{$lang_iso}The ISO code of the customer's language (en).
{$language_code}The language code of the customer's language (en-us).
{$languages}Used to access all languages.
{$link}Used to generate links to various pages.
{$logged}(deprecated) Whether the customer is logged in.
{$mail_dir}The relative URL to the mails directory.
{$meta_language}The ISO codes of all the active languages.
{$mobile_device}Whether the website is being viewed on a phone.
{$modules_dir}The relative URL to the modules directory.
{$opc}Whether one-page checkout is enabled.
{$page_name}The name of the current page (as displayed in the <body> tag).
{$pic_dir}Absolute URL to the customized image directory upload inside PrestaShop's root.
{$priceDisplay}Whether to display prices with or without tax.
{$priceDisplayPrecision}The number of decimal places to use in prices.
{$PS_CATALOG_MODE}Whether catalog mode is enabled.
{$PS_STOCK_MANAGEMENT}Whether stock management is enabled.
{$quick_view}Whether quick view is enabled.
{$request}The pagination link for the current page.
{$roundMode}The method of rounding prices.
{$shop_name}The shop's name.
{$shop_phone}The shop's phone number.
{$static_token}The static security token for the customer.
{$show_taxes}Whether to show taxes on a separate line.
{$time}The current time in milliseconds since January 1, 1970 00:00:00 GMT.
{$token}The customer's security token for the current page.
{$tpl_dir}The absolute URL to the current theme's directory.
{$tpl_uri}The relative URL to the current theme's directory without any protocol.
{$use_taxes}Whether to add taxes to prices.
{$vat_management}Whether the European VAT Number module is enabled.

Controllers

Here's a list of PrestaShop's controllers and a description of what each of them do:

Controller NameDescription
AddressController.phpUsed to edit a customer's address.
AddressesController.phpUsed to get a customer's addresses.
AttachmentController.phpUsed to download product attachments.
AuthController.phpUsed to manage customer login and registration.
BestSalesController.phpUsed to get the best-selling products.
CartController.phpUsed to manage the customer's cart.
CategoryController.phpUsed to get product categories.
ChangeCurrencyController.phpUsed to change the currency of prices.
CmsController.phpUsed to get a CMS page.
CompareController.phpUsed to compare products.
ContactController.phpUsed to send messages to employees.
DiscountController.phpUsed to get vouchers available to a customer.
GuestTrackingController.phpUsed to manage guest orders.
HistoryController.phpUsed to get a customer's orders.
IdentityController.phpUsed to get a customer's personal information.
IndexController.phpUsed to display the homepage.
ManufacturerController.phpUsed to get manufacturers and their products.
MyAccountController.phpUsed to display a customer's account page.
NewProductsController.phpUsed to get a list of new products.
OrderConfirmationController.phpUsed to manage the order confirmation page.
OrderController.phpUsed to manage the five-step checkout pages.
OrderDetailController.phpUsed to get a single customer order.
OrderFollowController.phpUsed to get a list of a customer's merchandise returns.
OrderOpcController.phpUsed to manage the one-page checkout page.
OrderReturnController.phpUsed to get a single merchandise return.
OrderSlipController.phpUsed to get a list of a customer's credit slips.
PageNotFoundController.phpUsed to manage the "Page not found" page.
ParentOrderController.phpUsed for shared ordering code.
PasswordController.phpUsed to allow a customer to reset a lost password.
PdfInvoiceController.phpUsed to download PDF invoices.
PdfOrderReturnController.phpUsed to download PDF merchandise returns.
PdfOrderSlipController.phpUsed to download PDF credit slips.
PricesDropController.phpUsed to get a list of discounted products.
ProductController.phpUsed to get a product.
SearchController.phpUsed to perform a search and get the results.
SitemapController.phpUsed to get the sitemap of the website.
StatisticsController.phpUsed to log OS and browser stats and page load time.
StoresController.phpUsed to get store information and Google map coordinates.
SupplierController.phpUsed to get suppliers and their products.

All controllers in PrestaShop extend the FrontController class. Here's a description of the FrontController members:

Member NameDescription
$authWhether a customer must log in before they can access the page.
$authRedirectionThe page redirected to after logging in.
$cart(deprecated) The current customer's or guest's cart.
$cookie(deprecated) Used to access PrestaShop's cookie variables.
$currentCustomerGroupsCaches the current customer's groups.
$display_column_leftWhether to display the left column on the page.
$display_column_rightWhether to display the right column on the page.
$errorsAn array of errors that have occurred.
$guestAllowedWhether a customer who has signed out can access the page.
$initializedWhether the init() function has been called.
$isoThe iso code of the currently selected language.
$link(deprecated) Used to generate PrestaShop links.
$maintenanceForces the maintenance page to be displayed.
$nThe number of items per page.
$nb_items_per_pageThe number of items per page.
$orderByThe field used to sort.
$orderWayWhether to sort ascending or descending ("ASC" or "DESC").
$pThe current page number.
$restrictedCountryForces the restricted country page to be displayed.
$smarty(deprecated) Used to access Smarty variables and functions.
$sslWhether the page is loaded using SSL when it is available.

Here's a description of the controller functions in the order they are executed:

Function NameDescription
__construct()Sets all the controller's member variables.
setMedia()Adds all JavaScript and CSS specific to the page so it can be combined, compressed and cached.
initHeader()Initialises the header variables.
initContent()Initialises the content variables.
initFooter()Initialises the footer variables.
display()Calls the Smarty templates and displays the page.