Get the contact email in PrestaShop, shop name and set values in cookies

If you need to get the contact email or the name of a PrestaShop installation:

$shop_email = strval(Configuration::get('PS_SHOP_EMAIL'));
$shop_name = strval(Configuration::get('PS_SHOP_NAME'));

If you also need to put values into cookies:

$this->context->cookie->__set('name_of your_key', $your_value);

To get the value from a smarty template (.tpl):


From PHP (inside a controller):

$this->context->cookie->name_of your_key

Outside of a controller:

$context = Context::getContext();
$context->cookie->name_of your_key;

I hope this helps :)

07:00 PM | Posted by | 0 comments

Disabling fancybox in Prestashop


Sometimes if you apply effects to your product images (like zooming) you want to avoid the “fancybox” effect what Prestashop shows by default.

This effect creates a popup window that shows an enlarged image of the product, usually when you visit the product’s page and click on it.

If you want to disable this effect in Prestashop 1.5 you must go to /themes/{name of your theme}/js/product.js, and there you must comment these lines:

‘hideOnContentClick’: true,
‘transitionIn’ : ‘elastic’,
‘transitionOut’ : ‘elastic’

You can comment this JavaScript code by sorrounding it with /* at the beginning and */ at the end.

This way your Prestashop will no longer show this behaviour!


12:47 PM | Posted by | 0 comments

Module URL in Prestashop

If you are working on a Prestashop module, and want to get the module URL inside a PHP file in your module, you just need this snippet (found in the “blocklayered” module):

$module_url = Tools::getProtocol(Tools::usingSecureMode()).$_SERVER['HTTP_HOST'].$this->getPathUri();

This returns the URL of the base directory of your module, so you can reference images or other files within your module. This is quite useful in backend forms of modules.


05:05 PM | Posted by | 0 comments

Smarty Prestashop variables

Here you have a list of the available Prestashop variables in Smarty, in a easily readable format:

01 $base_dir { root folder of your shop }
02 $base_dir_ssl { root folder of your shop using HTTPS protocol }
03 $content_dir { root folder of your shop depending on the SSL settings }
04 $img_ps_dir { root folder containing images “/img/” }
05 $img_dir { images folder in your current theme directory }
06 $css_dir { css folder inside the current theme folder }
07 $js_dir { JavaScript inside the theme folder }
08 $tpl_dir { theme root folder }
09 $modules_dir { modules root folder }
10 $mail_dir { mail templates root folder }
11 $lang_iso { current language ISO code }
12 $come_from { previous page address [absolute] }
13 $shop_name { your specified shop name }
14 $cart_qties { total number of products in the cart }
15 $cart { shopping cart contents }
16 $currencies { pulls available currencies }
17 $id_currency_cookie { selected currency id [cookie dependent] }
18 $currency { active currency }
19 $cookie { active cookie }
20 $languages { grabs available languages }
21 $logged { checks whether users is logged in }
22 $page_name { current page’s name }
23 $customerName { customer name [session dependent] }
24 $priceDisplay { current price display settings [currency dependent] }

Original source

04:36 PM | Posted by | 0 comments

Logging to file in Prestashop

If you need to debug a variable or function in Prestashop (PHP, not Smarty) you can use this piece of code. Logging in Prestashop is not very well documented, so I had to dive into the code to figure out how to do it:

$logger = new FileLogger(0); //0 == debug level, logDebug() won’t work without this.
$logger->logDebug(“message 1″);
$logger->logDebug(“message 2″);

Debug messages will look like this (inside “/log/debug.log” at root dir in Prestashop):

*DEBUG* 2014/02/11 – 14:31:48: Hello world

I hope this helps somebody :-). Cheers.

12:06 PM | Posted by | 2 comments