Child pages
  • Diving into PrestaShop Core development

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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 product links products to their category.

...

Method name and parameters

Description

getValidationRules($className = _CLASS_)

Return object validation rules (fields field 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's status in database.

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

Check for fields field validity before database interaction.

...

Some of the class' properties:

PropertyDescription
$templateTemplate name for page content.
$css_filesArray list of CSS files.
$js_filesArray list of JavaScript files.
$errorsArray 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.
$nThe number of items per page.
$orderByThe field used to sort.
$orderWayWhether to sort is ascending or descending ("ASC" or "DESC").
$pThe current page number.
$ajaxIf the ajax parameter is detected in request, set this flag to true.

...

Overriding a controller

Thanks to object inheritance, you can change a controller's behaviors, or add new ones.

...

Code Block
include_once('path_to_prestashop/config/config.inc.php');
include_once('path_to_prestashop/config/settings.inc.php');
include_once('path_to_prestashop/classes/Cookie.php');
$cookie = new Cookie('ps'); // Use "psAdmin" to read an employee's cookie.

Data stored in a visitor/client's cookie

 

TokenDescription
date_addThe date and time the cookie was created (in YYYY-MM-DD HH:MM:SS format).
id_langThe ID of the selected language.
id_currencyThe ID of the selected currency.
last_visited_categoryThe ID of the last visited category of product listings.
ajax_blockcart_displayWhether the cart block is "expanded" or "collapsed".
viewedThe IDs of recently viewed products as a comma-separated list.
id_wishlistThe ID of the current wishlist displayed in the wishlist block.
checkedTOSWhether the "Terms of service" checkbox has been ticked (1 if it has and 0 if it hasn't)
id_guestThe guest ID of the visitor when not logged in.
id_connectionsThe connection ID of the visitor's current session.
id_customerThe customer ID of the visitor when logged in.
customer_lastnameThe last name of the customer.
customer_firstnameThe first name of the customer.
loggedWhether the customer is logged in.
passwdThe MD5 hash of the _COOKIE_KEY_ in config/settings.inc.php and the password the customer used to log in.
emailThe email address that the customer used to log in.
id_cartThe ID of the current cart displayed in the cart block.
checksumThe Blowfish checksum used to determine whether the cookie has been modified by a third party.
The customer will be logged out and the cookie deleted if the checksum doesn't match.

Data stored in an employee/administrator's cookie

 

TokenDescription
date_addThe date and time the cookie was created (in YYYY-MM-DD HH:MM:SS format).
id_langThe ID of the selected language.
id_employeeThe ID of the employee.
lastnameThe last name of the employee.
firstnameThe first name of the employee.
emailThe email address the employee used to log in.
profileThe ID of the profile that determines which tabs the employee can access.
passwdThe MD5 hash of the _COOKIE_KEY_ in config/settings.inc.php and the password the employee used to log in.
checksumThe Blowfish checksum used to determine whether the cookie has been modified by a third party.
The If the checksum doesn't match, the customer will be logged out and the cookie is deleted if the checksum doesn't match .
  

Hooks

Hooks are a way to associate your code to some specific PrestaShop events.

...

This method receives one (and only one) argument: a table an array of the contextual information sent to the hook.

...