Prestashop – Customer data Export

In the previous tutorial Customer Password Migration – Prestashop to Magento, we were discussing about customer data migration from Prestashop to Magento. Through Prestashop admin panel, it’s not possible to export all customers data, so you need to write custom sql query to select all customer data in PHPMYADMIN and export CSV sheet.

Using following query you can select all customers who are having addresses.

select ps_customer.id_customer,, ps_customer.firstname,
ps_customer.lastname, ps_customer.passwd,,
ps_customer.birthday, ps_customer.newsletter,
ps_address.id_country, ps_address.id_state, ps_address.address1, ps_address.address2,
ps_address.postcode,,, ps_address.vat_number
from ps_customer INNER JOIN ps_address
ON ps_customer.id_customer=ps_address.id_customer;


Using following query you can select all customers who are not having addresses.

SELECT id_customer, email, firstname, lastname, passwd, company, birthday, newsletter
FROM ps_customer WHERE id_customer NOT IN (SELECT id_customer FROM ps_address);

Customize your query based on your need of customer attributes.

Customer Password Migration – Prestashop to Magento

To get the migrated passwords from Prestashop to Magento working, we need go through these 2 steps:

Step 1

Export customers from Prestashop.
In Prestashop, there is no straight forward method to export customers password, but you can always write your custom query to get the reuired information from database. Login to Prestashop admin section go to Advanced Parameters->SQL Manager and write a new sql query “select email, firstname, lastname, passwd from ps_customer; “ which will be used to select customers email id, firstname, lastname and password from customer table. If you want to select more fields, write your sql query accordingly. Afterwars export the information in csv file.

Step 2

The process through which Prestashop and Magento creates customer password is slightly different. Prestashop uses ‘Cookie Key’ prefix to the customer password, which is then MD5 encrypted. Magento uses MD5 and salt at the end. It’s not possible to convert passwords to plain text once it is encrypted using MD5 , so we need to rewrite customer authentication model to extend default validation process and validate passwords imported from Prestashop by adding prefix Cookie Key value to the passwords which was used to generate passwords in Prestashop.

Rewriting Mage_Customer_Model_Customer Model

1. Create a module with namespace Retailon and modulename Customerimport
2. Enable your Module in app/etc/modules/Retailon_Customerimport.xml

<?xml version="1.0"?>

3. Create config.xml file app/code/local/Retailon/Customerimport/etc/config.xml with following content:

<?xml version="1.0"?>

4. Create model file app/code/local/Retailon/Customerimport/Model/Customer.php with following content:

class Retailon_Customerimport_Model_Customer extends Mage_Customer_Model_Customer {

public function authenticate($login, $password)

if ($this->getConfirmation() && $this->isConfirmationRequired()) {
throw Mage::exception('Mage_Core', Mage::helper('customer')->__('This account is not confirmed.'),
if (!$this->validatePassword($password) && !$this->validatePassword('u4qrHpFiADz3peo8rS5tBkWARaa2WqN3qa7XqCI8iddIo7gdbj3KPNzGyK0'.$password)) {
throw Mage::exception('Mage_Core', Mage::helper('customer')->__('Invalid login or password.'),
Mage::dispatchEvent('customer_customer_authenticated', array(
'model' => $this,
'password' => $password,
return true;

5. You will see a long string prepended to the password variable in authenticate method, which is the cookie string used to generate passwords in Prestashop. Go to config/
file of your Prestashop project’s directory and you will see a line like

define('_COOKIE_KEY_', 'u4qrHpFiADz3peo8rS5tBkWARaa2WqN3qa7XqCI8iddIo7gdbj3KPNzGyK0'); 

Copy this string and replace the cookie sting of your Magento’s authenticate function.

That’s all you need to do. Now you should be able to login to Magento store using your Prestashop credentials.

In the next article Prestashop – Customer data Export, I’m going to write about How you can export customer data from Prestashop. Stay tuned.

Magento – Export last 3 months shipment information

Recently I was supposed to export shipping carrier, order number, shipment number and associated customer info of an order. Here goes the code:

SELECT orders.increment_id, grid.increment_id, grid.created_at, address.firstname, address.lastname,, track.track_number, title-- prior to 1.6 `track_number` should be `number`
FROM sales_flat_order AS orders
JOIN sales_flat_order_address AS address ON address.parent_id = orders.entity_id
JOIN sales_flat_shipment_grid AS grid ON grid.order_increment_id = orders.increment_id
JOIN sales_flat_shipment_track AS track ON track.order_id = orders.entity_id
WHERE address.address_type =  'shipping' and grid.created_at >= '2015-04-10'

Modify it according to your need and export the sheet.