ZenCart to Magento import

791 views Asked by At

I am looking to migrate ZenCart "customers" to an existing Magento website. I tried two extensions from MagentoConnect; however it doesn't works.

osCommerce Migration Tool osCommerce Import

There are premium 3rd party migration services available in market, however I would like to do this my own. Please help me out by providing some steps to this through code.

Currently the zen cart DB is having prefix "zen_". Will this be causing inconvenience ? please point me out a starting point on this. Thanks

1

There are 1 answers

0
Leo Prince On BEST ANSWER

I have sorted this my own. What surprised me is, there are no valid doc on how to import customers from ZenCart/OsCommerce to Magento any where around web unless some forum with premium Magento extensions. Hence I am posting my solution here which would be a help for any one who is looking for this same solution.

Fetching ZenCart customer details

Obviously ZenCart uses MySQL DB. Get into MySQL prompt and look into the customers table. Use the below command respectively.

use ZenCart_DB
mysql> select * from customers\G

You can see the details of your ZenCart customers there. Sample output will be like this per customer.

customers_id: 1298
        customers_gender: m
     customers_firstname: firstname
      customers_lastname: Lastname
           customers_dob: 
 customers_email_address: [email protected]
          customers_nick: 
customers_default_address_id: 
     customers_telephone: 12345678
           customers_fax: 
      customers_password: dd2df54a57a4d35ffd2985b3584f0831:2c
    customers_newsletter: 0
 customers_group_pricing: 0
  customers_email_format: TEXT
 customers_authorization: 0
      customers_referral: 
customers_paypal_payerid: 
     customers_paypal_ec: 0
           COWOA_account: 0

This is a sample and we have to take all these customer details to a unix file.

select * from customers into outfile 'customer.txt'\G

Now come out of MySQL prompt. To create a Magento user, we only need firstname,lastname,email and password. These four details are mandatory. Hence grep those details from the customer.txt file.

The location of customer.txt file will be /var/lib/mysql/ZenCart_DB/customer.txt

Grep the required customer details to different individual files which will help us to put them into for loop later.

awk {'print $3,$4,$7,$10'} customer.txt > details.txt
awk {'print$1'} details.txt > zen_firstname
awk {'print$2'} details.txt > zen_secondname
awk {'print$3'} details.txt > zen_email
awk {'print$4'} details.txt > zen_password

Creating a Magento user

No we have collected all the details. Now to create a test Magento user from backend, we have to run 5 MySQL queries in magento database. They are,

INSERT INTO customer_entity ( entity_id, entity_type_id, attribute_set_id, website_id, email, group_id, increment_id, store_id, created_at, updated_at, is_active, disable_auto_group_change) VALUES ( 1, 1, 0, 1, $email, 1, NULL, 4, 2014-11-24 11:50:33, 2014-11-24 12:05:53, 1, 0)

INSERT INTO customer_entity_varchar (value_id, entity_type_id, attribute_id, entity_id, value) VALUES (1, 1, 5, 1, $firstname);

INSERT INTO customer_entity_varchar (value_id, entity_type_id, attribute_id, entity_id, value) VALUES (2, 1, 7, 1, '$lastname' );

INSERT INTO customer_entity_varchar (value_id, entity_type_id, attribute_id, entity_id, value) VALUES (3, 1, 12, 1, '$password' );

INSERT INTO customer_entity_varchar (value_id, entity_type_id, attribute_id, entity_id, value) VALUES (5, 1, 3, 1, 'English' );

If you have too many customers to add, then better put them in for loop. This is optional for each person. we can create for loop in bash or similar in Perl or what ever language you are good at.

Few things to note,

  • entity_id value is important and it should be the same in all the 5 queries. It determines the customer's ID number.
  • value_id is like serial number to the rows in table customer_entity_varchar. Follow the sequence as it is.
  • attribute_id should be kept as it is in the sequence 5,7,12,3 as it represents customers firstname, lastname, password, language respectively.

That's all I think. Thanks. :)