Outils pour utilisateurs

Outils du site


webdev:prestashop:start

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
webdev:prestashop:start [26/06/2017 17:24] dolowebdev:prestashop:start [07/07/2017 16:37] (Version actuelle) – [Charger un module dans un controller / override :] dolo
Ligne 1: Ligne 1:
 +====== Prestashop ======
 +  * [[http://doc.prestashop.com/display/PS16/PHP+Coding+Standards|Coding standards 1.6]]
 +  * [[http://doc.prestashop.com/display/PS16/System+Administrator+Guide#SystemAdministratorGuide-NginxfriendlyURLs|System administrator guide]]
 +
 +===== Accéder à la BDD : =====
 +[[http://doc.prestashop.com/display/PS16/Best+Practices+of+the+Db+Class|Doc 1.6]]
 +<Code>Db::getInstance()->méthodes</Code>
 +
 +==== Échapper les caractères : ====
 +<Code:php><?php
 +/**
 + * Sanitize data which will be injected into SQL query
 + *
 + * @param string $string SQL data which will be injected into SQL query
 + * @param bool $htmlOK Does data contain HTML code ? (optional)
 + * @return string Sanitized data
 + */
 +  pSQL($string, $htmlOK);
 +</Code>
 +
 +Ou **bqSQL()** :
 +> bqSQL() can also be used. Note that besides escaping the ` character, it also calls pSQL() afterwards, but without the option to sanitize HTML.
 +
 +  
 +===== Récupérer l'ID customer : =====
 +<Code>
 +  $context = Context::getContext();
 +  echo 'ID customer : '. $context->customer->id;
 +</Code>
 +  
 +===== Charger un module dans un controller / override : =====
 +Ne pas faire :
 +<Code>require_once(_PS_MODULE_DIR_.'/projets/projets.php');</Code>
 +Mais plutôt :
 +<Code>$projets = Module::getInstanceByName('projets');</Code>
 +
 +**Fonctions utiles pour dev :**\\
 +http://nemops.com/prestashop-functions-1/#.Vb8upPnzrmg
 +
 +------------------
 +<Code>
 +$this->context->cookie->id_lang //Lang ID
 +$this->context->customer->id_lang // Probably better than the above
 +</Code>