Table of content
Table of Contents | ||
---|---|---|
|
...
Public and overloadable methods
...
Tip | ||
---|---|---|
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.
|
ObjectModelCore (ObjectModel.php)
This is the main object from PrestaShop's object model. Any overriding of its methods is bound to influence how all the other classes and methods act. Use carefully.
Method name and parameters | Description |
---|---|
getValidationRules($className = _CLASS_) | Return 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) | Return the set protocol according to configuration (https). |
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') | Add a 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 databasedisplayFlags($languages, $defaultLanguage, $ids, $id, $return = false) | Display flags in forms for translations. |
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. 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. | |
l($string, $class = 'AdminTab', $addslashes = FALSE, $htmlentities = TRUE) | use translations files to replace english expression. | |
postImage($id) | Overload this method for custom checking in postProcess()'s object creation/update routine. | |
validateRules($className = false) | Manage page display (form, list...).0 |
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). |
getTranslationsFieldsChild() | Check then return multilingual fields for database interaction. |
set($key, $values) | Set TEMPORARY a single configuration value (in one language only). |
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. |
getFamily($origin) | Get a family of variables (e.g. "filter_"). |
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. |
setExpire($expire) | Set expiration date. |
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. |
pSQLgetInstance($string, $htmlOK $master = false) Sanitize data which will be injected into SQL query1) | Get Db object instance (Singleton). |
nl2br2($string) | Convert \n and \r\n and \r to <br />. |
...
pSQL($string, $htmlOK = false) | Sanitize data which will be injected into SQL query. |
FrontControllerCore (FrontController.php)
Method name and parameters | Description |
---|---|
getProductDeletePictureLinkpreProcess($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) |
|
getCMSCategoryLinkOverload 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. |
LinkCore (Link.php)
Method name and parameters | Description | ||
---|---|---|---|
addSortDetails($url, $orderby, $orderway) | |||
getCategoryLink($id_category, $alias = NULL, $id_lang = NULL) | |||
getCMSLinkgetCatImageLink($cms, $alias = null, $ssl = false, $id_lang = NULL$name, $id_category, $type = null) | |||
getSupplierLinkgetCMSCategoryLink($id_suppliercategory, $alias = NULL, $id_lang = NULL) | |||
getManufacturerLinkgetCMSLink($id_manufacturer$cms, $alias = NULLnull, $ssl = false, $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, getLangLink($id_lang = NULL) | |||
getCatImageLink($name, $id_category, $type = null) |
| ||
getLanguageLink($id_lang) | Create link after language change, for the change language block. | ||
goPagegetManufacturerLink($url, $p$id_manufacturer, $alias = NULL, $id_lang = NULL) | |||
getMediaLink($filepath) | |||
getPageLink($filename, $ssl = false, $id_lang = NULL) | |||
getPaginationLink($type, $id_object, $nb = false, $sort = false, $pagination = false, $array = false) | |||
addSortDetailsgetProductDeletePictureLink($url, $orderby, $orderway) |
| getLangLink($id_$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. | ||
getSupplierLink($id_supplier, $alias = NULL, $id_lang = NULL) | |||
goPage($url, $p) | |||
preloadPageLinks() |
MailCore (Mail.php)
Method name and parameters | Description |
---|---|
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. |
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 |
ObjectModelCore (ObjectModel.php)
This is the main object from PrestaShop's object model. Any overriding of its methods is bound to influence how all the other classes and methods act. Use carefully.
Method name and parameters | Description |
---|---|
__construct($id = NULL, $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. |
...
NULL) | Build object. |
add($autodate = true, $nullValues = false) | Save current object to database (add or update). |
delete() | Delete current object from database. |
deleteSelection($selection) | Delete several objects from database. |
getFields() | Prepare fields for ObjectModel class (add, update). |
getValidationRules($className = _CLASS_) | Return object validation rules (fields validity). |
save($nullValues = false, $autodate = true) | Save current object to database (add or update). |
toggleStatus() | Toggle object status in database. |
update($nullValues = false) | Update current object to database. |
validateFields($die = true, $errorReturn = false) | Check for fields validity before database interaction. |
PDFCode (PDF.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. |
Footer() | Invoice footer. |
Header() | Invoice header. |
ToolsCore (Tools.php)
Method name and parameters | Description |
---|---|
addCSS($css_uri, $css_media_type = 'all') | Add a stylesheet at any time. |
addJS($js_uri) | Load a javascript file in the header. |
cccCss() | Combine Compress and Cache (ccc) CSS calls. |
cccJS() | Combine Compress and Cache (ccc) JS calls. |
convertBytes($value) | Convert a shorthand byte value from a PHP configuration directive to an integer value. |
convertPrice($price, $currency = NULL, $to_currency = true) | Return price converted. |
dateDays() | |
dateFormat($params, &$smarty) | Display date regarding to language preferences. |
dateFrom($date) | |
dateMonths() | |
dateTo($date) | |
dateYears() | Generate date form. |
deleteDirectory($dirname, $delete_self = true) | Delete directory and subdirectories. |
dieObject($object, $kill = true) | Display an error with detailed object. |
displayDate($date, $id_lang, $full = false, $separator = '-') | Display date regarding to language preferences. |
displayError($string = 'Fatal error', $htmlentities = true) | Display an error according to an error code. |
displayPrice($price, $currency = NULL, $no_utf8 = false) | Return price with currency sign for a given product. |
encrypt($passwd) | Encrypt password. |
getAdminToken($string) | Encrypt password. |
getCurrentUrlProtocolPrefix() | Get the current url prefix protocol (https/http). |
getHomeMetaTags($id_lang, $page_name) | Get meta tags for a given page. |
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. |
getMetaTags($id_lang, $page_name) | Get meta tages for a given page. |
getPath($id_category, $path = '', $linkOntheLastItem = false, $categoryType = 'products') | Get the user's journey. |
getProductsOrder($type, $value = null) | Get products order field name for queries. |
getProtocol($use_ssl = null) | Return the set protocol according to configuration (https). |
getRemoteAddr() | Get the server variable REMOTE_ADDR, or the first ip of HTTP_X_FORWARDED_FOR (when using proxy). |
getServerName() | Get the server variable SERVER_NAME. |
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. |
getToken($page = true) | Get token to prevent CSRF. |
getValue($key, $defaultValue = false) | Get a value from $_POST / $_GET. If unavailable, take a default value. |
isSubmit($submit) | Check if submit has been posted. |
jsonDecode($json, $assoc = false) | Convert json string to php array / object. |
link_rewrite($str, $utf8_decode = false) | Return the friendly url from the provided string. |
passwdGen($length = 8) | Random password generator. |
redirect($url, $baseUri = _PS_BASE_URI_) | Redirect user to another page. |
redirectAdmin($url) | Redirect user to another admin page. |
redirectLink($url) | Redirect url wich allready PS_BASE_URI. |
safeOutput($string, $html = false) | Sanitize a string. |
secureReferrer($referrer) | Secure an URL referrer. |
setCookieLanguage() | Change language in cookie while clicking on a flag. |
setCurrency() | Set cookie currency from POST or default currency. |
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. |
switchLanguage() | Set cookie id_lang. |
toCamelCase($str, $capitaliseFirstChar = false) | Translates a string with underscores into camel case (e.g. first_name -> firstName). |
truncate($str, $maxLen, $suffix = '...') | Truncate strings. |
usingSecureMode() | Check if the current page use SSL connection on not. |
ZipExtract($fromFile, $toDir) | Extract a zip file to the given directory. |
ZipTest($fromFile) | Try to open a zip file in order to check if it's valid. |
ValidateCore.php
Method name and parameters | Description |
---|---|
IsSortDirection($value) | Check if the value is a sort direction value (DESC/ASC) |
isAbsoluteUrl($url) | Check object validity |
isAddress($address) | Check for a postal address validity |
isArrayWithIds($ids) | isArrayWithIds() |
isBirthDate($date) | Check for birthDate validity |
isCarrierName($name) | Check for a carrier name validity |
isCatalogName($name) | Check for product or category name validity |
isCityName($city) | Check for city name validity |
isCleanHtml($html) | Check for HTML field validity |
isColor($color) | Check object validity |
isConfigName(string $configName) | Check for configuration key validity |
isCookie(mixed $data) | Check if $data is a PrestaShop cookie object |
isCoordinate(string $data) | Check for Latitude/Longitude |
isCountryName(string $name) | Check for a country name validity |
isDate(string $date) | Check for date validity |
isDateFormat(string $date) | Check for date format |
isDiscountName(string $discountName) | Check for discount coupon name validity |
isDistanceUnit($unit) | isDistanceUnit() |
isDniBool(string $dni) | Check for Dni validity |
isEan13(string $ean13) | Check for barcode validity (EAN-13) |
isEmail(string $email) | Check for e-mail validity |
isFileName(string $name) | Check for standard name file validity |
isGenderIsoCode(string $isoCode) | Check for gender code (ISO) validity |
isLangIsoCode(string $iso_code) | Check for Language Iso Code |
isLinkRewrite(string $link) | Check for a link (url-rewriting only) validity |
isMd5(string $md5) | Check for MD5 string validity |
isPasswd(string $passwd, $size) | Check for password validity |
isPhoneNumber(string $phoneNumber) | Check for phone number validity |
isPhpDateFormat(string $date_format) | Check date formats like http://php.net/manual/en/function.date.php |
isPostCode(string $postcode) | Check for postal code validity |
isSerializedArray(string $data) | Check for PHP serialized data |
isSha1(string $sha1) | Check for SHA1 string validity |
isUpc(string $upc) | Check for barcode validity (UPC) |
isUrl(string $url) | Check url valdity (disallowed empty string) |
isUrlOrEmpty(string $url) | Check url validity (allowed empty string) |
isZipCodeFormat(string $zip_code) | Check for zip code format validity |