Search the Community
Showing results for tags 'zen-cart'.
-
Hi there! This is my first contribution to the community. I hope it helps someone. I would like to share my approach on how to integrate Zen-Cart / OSCommerce passwords with Prestashop. I have a Zen-Cart shop with 50k registered customers which I am migrating to Prestashop. The "Back Office -> Tools -> CSV Import" tool works like a charm to import your customers but they will not be able to login on Prestashop because passwords are encrypted in different ways on both store managers. This solution requires no database modification (aside from creating a support table) and only one php code modification (/classes/Customer.php). It will let your legacy customers login and change passwords through admin panel or "forgot my password" if they'd like. Actually they would not notice anything different at all. If you want to understand some of the inner workings of both systems, I would recommend you to learn a little about password hashing and hash salting. You can skip this part if you want to get your hands dirty fast. How Zen-Cart / OSCommerce passwords work: Format: 32 alphanumeric characters + colon + 2 alphanumeric characters salt E.g: e56d64755f66a86996b54114bb4102bf:08 35 characters total It has a salting function which generates a random salt for every password. The password is hashed with MD5 and salted with 2 aditional characters. These two aditional characters are then appended to the password with a colon. How Prestashop passwords work: Format: 32 alphanumeric characters (a standard MD5 salted hash) E.g: e56d64755f66a86996b54114bb4102bf 32 characters total It uses a per-installation random constant called _COOKIE_KEY_ as salt. As you can see, they simply don't match. After some tries, I ended up with the following solution: ================================== IMPORTANT NOTES: - It works for Prestashop V1.4.7X (needs to be tested for other versions); - DO A BACKUP BEFORE ANY CHANGES IN YOUR DATABASE/CODE; - Try it in a development environment; - I'm obviously not responsible if you screw your shop; - Have I already mentioned to do backups? - English is my second language. Sorry you grammar nazis. DATABASE: 1) Export the prefix_customers table from Zen-Cart / OSCommerce / OpenCart into a CSV file; 2) Import your users through Prestashop's CSV Import tool; 3) Create this table in your Prestashop database: CREATE TABLE zc_legacy_passwords ( id INT NOT NULL, PRIMARY KEY(id), email VARCHAR(100), password VARCHAR(35), updated BOOLEAN NOT NULL ); 4) Populate this table using the previously created .CSV file or create a .SQL file from the following query and import into the zc_legacy_passwords table: SELECT customers_id, LOWER(customers_email_address), customers_password FROM PREFIX_customers ORDER BY customers_id Now we have all the data needed to allow our customers log into Prestashop, but we still need to change how the login process work. CODING STEPS: Modify the /classes/Customer.php file with the following: 1) Look for the public function getByEmail($email, $passwd = NULL) <- line 203 2) Replace lines 217 and 218, turning it from... if (!$result) return false; ...to... // == BEGIN ZEN-CART / OSCOMMERCE TO PRESTASHOP PASSWORD INTEGRATION == // == BY João Cunha - [email protected] // == @ 31/03/2012 // == USE AND MODIFY AT WILL // == TESTED ON PRESTASHOP V1.4.7X if (!$result) { //<- INVALID PRESTASHOP LOGIN, IT MAY BE A ZEN-CART / OSCOMMERCE PASSWORD //CHECK IF THE GIVEN EMAIL MATCHES A ROW IN OUR LEGACY TABLE AND RETRIEVES THE LEGACY PASSWORD $resultZC = Db::getInstance()->getRow(' SELECT `password` FROM `zc_legacy_passwords` WHERE `email` = \''.pSQL($email).'\' AND `updated` = 0'); if (!$resultZC) return false; //<- EMAIL NOT FOUND IN NONE OF THE TABLES, SO IT IS AN INVALID LOGIN //ENCRYPTS THE GIVEN PASSWORD IN ZEN-CART / OSCOMMERCE FORMAT $salt = substr($resultZC['password'], strrpos($resultZC['password'],':')+1, 2); $ZCpassword = md5($salt . $passwd) . ':' . $salt; if ($ZCpassword != $resultZC['password']) return false; //<- WRONG ZEN-CART/OSCOMMERCE PASSWORD GIVEN //WE'LL UPDATE THE CUSTOMER TABLE WITH ITS PRESTASHOP ENCRYPTED PASSWORD... Db::getInstance()->Execute(' UPDATE `'._DB_PREFIX_ .'customer` SET `passwd` = \''.md5(pSQL(_COOKIE_KEY_.$passwd)).'\' WHERE `email` = \''.pSQL($email).'\''); //...AND FLAG IT AS UPDATED, SO THE NEXT TIME HE LOGS IN, HE WON'T ENTER THIS ROUTINE. Db::getInstance()->Execute(' UPDATE `zc_legacy_passwords` SET `updated` = 1 WHERE `email` = \''.pSQL($email).'\''); //USER IS AUTHENTICATED, OVERWRITE THE EMPTY $result VARIABLE $result = Db::getInstance()->getRow(' SELECT * FROM `'._DB_PREFIX_ .'customer` WHERE `active` = 1 AND `email` = \''.pSQL($email).'\' AND `deleted` = 0 AND `is_guest` = 0'); } // == END ZEN-CART / OSCOMMERCE TO PRESTASHOP PASSWORD INTEGRATION ================================== And you're done! I don't know if there is another way of achieving the same results without modifying the Customer.php core file, but that would be great. Since I'm a Prestashop noob, I would like to hear any thoughts from you guys. Cheers, João Cunha Brazil
- 33 replies
-
- 5
-
I couldn't figure out how to use the oscommerce importer to migrate a site from zen-cart to prestashop as other have suggested. So I've started just creating csv files from the zen-cart db and using them to import into the new prestashop site. The issue I'm having now is with customer passwords. Password encryption is a bit different between the two applications. Does anyone know how to import the passwords in a way that would allow customers to use the same password without having to change it. I'd also like to keep order history if possible but I didn't see a method provided for this. Anyone have experience doing this moving directly from the zen-cart db to the prestashop db directly?
-
I have been a web store owner for several years and have used zen-cart, opencart, magento, prestashop trying to build up a web shop. I only know some basic html and php programming skill. Now I would like to share my limited experience with some beginners who want to build up an onlne shop. Hope it is helpful to someone. The very first shop I tried to set up is this Sex Toy Wholesaler Store, with zen-cart 1.38a in 2009 on a shared hosting plan from BlueHost. At that time, zen-cart was a highly recommended platform. I was generally satisfied with it as it worked fine and received orders for us, eventhough the site did not look very nice. There was one serious problem with zen-cart when I used it: my site was hacked many times (now I think this was mainly due to the unsecured enough shared hosting)! I encountered opencart by coincidence after two years and a half or so and surprisingly found that this software was just way better looking than zen-cart. So I searched through internet for the comparison of major open source e-commerce software online and read a lot about this. I then switched the Sex Toy Wholesaler Store to opencart and was happier. Meanwhile, I still looked for other better alternatives and see if I could do better (Opencart did not offer rich SEO settings by default). I have tried prestashop and magento. Prestashop was really impressive as well. It provided a nice clean default theme and the SEO settings seemed to be sufficient. It also offered rich ajax feature, streamline one page checkout, abandoned cart reminder etc. And I really like it. However, as I spent more time testing prestashop (maybe not enough time as I feel that I am still not very familiar with it), I found its shopping cost setting really disappointed. Because I had to input more than 1,000 values to complete our shipping cost settings for different countries worldwide. I think prestashop is the best for those merchants who shipping cost calculation method is simple. And I might use it to build up another shop in the future. As for magento, it is really a masterpiece of e-commerce and I love it IF I HAD ENOUGH BUDGET! This boy just requires high end server hardware and better programming skill to run it well.