E-commerce Web Development

[SOLVED] Prestashop backoffice login refresh

When trying to log into my PrestaShop backoffice, the page was reloading / refreshing without any errors!
After much investigations (3hours non stop!) I found out this solution:
In the file “login.php” under your backoffice’s folder,
on line 55, you have:

 $cookie = new Cookie('psAdmin', substr($_SERVER['PHP_SELF'], strlen(__PS_BASE_URI__), -10));

where the “-10” value corresponds to the number of letters of “prestashop”, set it to the number of letters of your store’s subdirectory name and your will be back to the business again.
For exemple:
if your store is located at:
the word “store” contains 5 letters, so the line 55 in login.php should become:

$cookie = new Cookie('psAdmin', substr($_SERVER['PHP_SELF'], strlen(__PS_BASE_URI__), -5));

What I found out again, is that Prestashop is a very bad done software and not ready for business. I will switch to a better e-commerce solution!


Add a Google +1 button to your PrestaShop store for Free!

Today I’m going to give you some great news.


Online stores, e-commerce software…

More than 50 thousand online stores run on PrestaShop, an online e-commerce software. There are lots of advantages using this software, e.g. it’s open source, it’s got a huge community of developers and users, lots of modules and themes are being added to it regularly…


PrestaShop’s Drawback

But the main drawback of PrestaShop is that most of its modules are not free and to run a decent business you gonna spend a lot of money over the modules. Well, I would recommend to buy the modules you need without hesitation, because it is an investment in your business, but I know that you are looking for the Free ones at first.


Google +1

You’ve certainly heard of the “+1” button from Google, and it would be nice to add it to your shop so that your users can recommend your products on Google.

There are modules on the PrestaShop’s market to allow you putting a “Google +1” button to you store, and they are priced at around 40€ (about 50USD).


Free Google +1 for PrestaShop

oGooglePlusOne module Logo

The great news is that offers a “Google +1” button for PrestaShop, completely FREE! and that saves you about 50USD!


As you know, you can donate to thank the developer ;)


I got a copy of the oGooglePlusOne module from and tested it on one of my e-commerce websites. It is complete and integrates itself automatically! Go to and grab yourself a Free copy of oGooglePlusOne for Prestashop!


Don’t forget to say Thank You and send a donation if you think it’s worth it.


Embed Images in PHPMailer

I’ll keep this one short and fast:

PHPMailer has lots of features, even if it’s a bit old.

One great feature is that it allows you to embed images inline within your e-mail’s body. In most email clients, the inline embedded images are shown in their right place just as on a web page and are “also” in the attachements list.

To be able to use this feature, proceed as follows:

1- Instantiate PHPMailer:

$mail = new PHPMailer(true);
//Path to image file (use full path)
$filepath= '/path/to/file/logo_mail.jpg';
//File token ID, use unique interger.
$filecid = 1001;
//File name which will be in the mail, overrides default filename.
$filename= 'shop-logo.jpg';
$encodingtouse = 'base64';
//File type MIME
$filemime = 'image/jpeg';
$mail->AddEmbeddedImage($filepath, $filecid, $filename, $encoding, $filemime);
//Message Html Body

2- In your /path/to/contents.html file, which is your mail template message, you can include the inline image. Use this syntax for the <img> tag:

<img src=”cid:1001” alt=”shop logo used in emails” width=”182″ height=”75″ />

Note the CID here, it should be the same as the one you defined for your embedded inline image.

Tested and working with PHPMailer 5.1 on GMAIL, Yahoo!Mail and Mac Mail application




[SOLVED] Could not instantiate mail function in PHPMailer

(This article has an advanced technical level, written for people with PhpMailer experience.)

PHPMailer 5.1 in PrestaShop 1.4

Trying to integrate PHPMailer in Prestashop and use it instead of SWIFT Mailer 3 (which is the default mailer script included with Prestashop 1.4), I spent hours to no avail and was getting the Could not instantiate mail function error.

mail() function

The mail() function by itself  was working correctly before and after loading Prestashop and every passed argument seemed to be correct. I did get the “Bad parameters to mail() function, mail not sent” error for mail() too.

Debugging and Abracadabra!

I’ve done lots of debugging and found in my case that the following functions were causing the error, when passing the $Subject parameter to mail():


To solve the “Could not instantiate mail function” error in PHPMailer, I removed the above 2 functions from the mail() function arguments.

Just be careful to remove these functions correctly from all places in your class.phpmailer.php.

I recommend using the PHP function


because it encodes your stuff correctly for the headers in emails.

To be more clear,

1- open the PHPMAILER class file (class.phpmailer.php)

2- Locate:

protected function MailSend($header, $body)

function and in its body,

3- In every call to mail(),

replace this:

@mail($val, <strong>$this->EncodeHeader($this->SecureHeader($this->Subject))</strong>, $body, $header, $params);

by this:

@mail($val, <strong>mb_encode_mimeheader($this->Subject,$this->CharSet, 'B', '')</strong>, $body, $header, $params);


This way you are sure to correctly encode your subjet.

Remember to set the correct Charset for your PHPMAILER instance. That is, when calling PHPMailer, just after:

$mail=new PHPMailer(true);


$mail->CharSet = 'UTF-8';

(or any other charset you need).

This solved my “Could not instantiate mail() function in PHPMailer issue. I hope it helps you out if you got this issue too.


I’ll write more about PHPMailer and PrestaShop later,

In my next post, learn how to correctly include inline images in PHPMailer email to display in GMAIL, YAHOO, Mac Mail app and other email clients correctly as inline images.


Bug Prestashop, la liste des magasins n'apparait pas

Cette article est sponsorisé par¦works

En plein developpement

En plein développement de plusieurs modules PrestaShop, j’ai rencontrer plusieurs souci dans les code du package PrestaShop. Ce qui m’étonne, c’est qu’il y a beaucoup de gens qui utilise PrestaShop, même si c’est du gros n’importe quoi en terme de codage et programmation.


Alors pourquoi je créer des module?

Tout simplement parcequ’il y a de la demande.

(Restez connecté pour avoir des nouvelles de mes modules:

Ces modules sont créer pour et seront sont disponible sur

Retour à nos moutons

Je vous explique un bug que j’ai trouver aujourd’hui et la solution.

Le problème est ceci:

La variable SMARTY qu’utilise PrestaShop pour stocker les informations des magasin est nomée “$stores”. On peut y acceder et donc afficher les details de nos magasin un peu partout dans les pages et les modules sans diriger le visiteur sur la page de “nos-magasin”.Module Contact PrestaShop avec formulaire de contact et carte google maps

Quand vous changez la configuration de l’affichage simplifié dans le Back Office, la variable $stores devient VIDE partout sur votre boutique. Donc vous ne pouvez plus afficher les details comme un numéro téléphone ou une photo tiré directement de la variable $stores.

Ceci est du au faite que une fois la configuration dans le Back Office modifié, PrestaShop relance une requete vers la base de donnée pour recréer $stores, mais cette fois il relance la requete en cherchant a calculer un distance! Donc la variable $stores reste vide.

Essayez d’ouvrir votre boutique en ligne en ajoutant “?all=1” à la fin de votre URL et vous verrez que la variable $stores fonctionne correctement et affiche bien les infos de vos magasins.

Remède, Solution

Le remède a ceci est de modifier le fichier

PSdir ->controllers -> StoresController.php

qui gère la variable $stores.


Au environs de la ligne 73, on ajoute une nouvelle requete SQL qui remplit la variable $stores avec la liste de tous nos magasins, et une deuxième requete SQL qui servira a calculer la distance en cas de recherche.

$stores = Db::getInstance()->ExecuteS(' SELECT s.*, country, st.iso_code state FROM '._DB_PREFIX_.'store s LEFT JOIN '._DB_PREFIX_.'country_lang cl ON (cl.id_country = s.id_country) LEFT JOIN '._DB_PREFIX_.'state st ON (st.id_state = s.id_state) WHERE = 1 AND cl.id_lang = '.(int)($cookie->id_lang)); $results = Db::getInstance()->ExecuteS(' SELECT s.*, country, st.iso_code state, ('.(int)($multiplicator).' * acos(cos(radians('.(float)(Tools::getValue('latitude')).')) * cos(radians(latitude)) * cos(radians(longitude) - radians('.(float)(Tools::getValue('longitude')).')) + sin(radians('.(float)(Tools::getValue('latitude')).')) * sin(radians(latitude)))) distance, cl.id_country id_country FROM '._DB_PREFIX_.'store s LEFT JOIN '._DB_PREFIX_.'country_lang cl ON (cl.id_country = s.id_country) LEFT JOIN '._DB_PREFIX_.'state st ON (st.id_state = s.id_state) WHERE = 1 AND cl.id_lang = '.(int)($cookie->id_lang).' HAVING distance < '.(int)($distance).' ORDER BY distance ASC LIMIT 0,20');

A savoir que la variable $results sera vide si il n’y a pas de demande de recherche de distance et donc StoresController.php ne genèrera pas de fichier XML servant a la mise en place d’une carte Google Maps dans le Store Locator. Pour assurer que le fichier XML sera créer seulement si $results contient quelque chose, je fait une verification avec:

if (!empty($results))

Téléchargez, tout simplement

Vous pouvez télécharger la version corrigée de ce fichier dans la page téléchargement de (nom du fichier:


Pour l’utiliser,

1- Allez dans:


2- Renommez votre present fichier StoresController.php en StoresController.php.bak,

3- Placez le fichier php que vous avez télécharger et décompresser dans le même dossier.


Maintenant la variable $stores est de nouveau accessible, quelconque la configuration dans le Back Office de PrestaShop.

Je souhaite un grand succès à la communauté PrestaShop et j’espère qu’un jour ils auront du code concrete, correcte, scientifiquement étudié et structuré.

Cette article est sponsorisé par¦works

Web Development

Prestashop gets jQuery 1.4.4

Prestashop with latest jQuery.

At last! I’m very excited to announce that Prestashop is getting the jQuery 1.4.4 library update! This has been implemented in Prestashop 1.4 Alpha 4 version, which as tha name says it, is an alpha version and is probably not enough stable to become your “live” shop. I want to thank the Prestashop team, and invite all of you to try to develop more and more Prestashop modules and themes and make Prestashop the “WordPress” of e-commerce!

Lots of new features for this e-commerce package.

Here’s the change log, where you can find lots of new added features and possibilities:

One this to mention, is the SMARTY template engine upgrade to 3.5 for better performances.

Prestashop’s API?

One great feature added recently is the Webservice feature. It looks like an advanced API. As says the e-commerce’s newsletter “The Webservice is a fabulous tool to develop customized features in a simple and fast way!” Go to Prestashop’s blog to find out more: