The database structure
By default, PrestaShop's database tables start with the ps_
prefix. This can be customized during installation
All table names are in lowercase, and words are separated with an underscore character ("_
"):
ps_employee
ps_manufacturer
ps_product
ps_product_comment
ps_shop_url
When a table establishes the links between two entities, the names of both entities are mentioned in the table's name. For instance, ps_category_product
links products to their category.
A few details to note about tables:
Tables which contain translations must end with the
_lang
suffix. For instance,ps_product_lang
contains all the translations for theps_product
table.Tables which contain the records linking to a specific shop must end with the
_shop
suffix. For instance,ps_category_shop
contains the position of each category depending on the store.
There is also a couple of standard practices for data rows within a table:
Use the
id_lang
field to store the language associated with a record.Use the
id_shop
field to store the store associated with a record.
The DBQuery class
The DBQuery class is a query builder which helps you create SQL queries. For instance:
Here are some of the methods from this class:
The ObjectModel class
When needing to dive deep, you have to use the ObjectModel class. This is the main object of PrestaShop's object model. It can be overridden... with precaution.
Defining the model
You must use the $definition
static variable in order to define the model.
For instance:
A model for many stores and/or languages
In order to retrieve an object in many languages:
In order to retrieve an object depending on the current store
In order to retrieve an object which depends on the current store, and in many languages:
The main methods
Any overriding of the ObjectModel methods is bound to influence how all the other classes and methods act. Use with care.
Last updated
Was this helpful?