Recently, I helped Loveknitting to import customer information into a OpenCart-based web shop. The database structure used by OpenCart is quite intuitive so figuring out what information that was needed was relatively easy. Customer's password were not imported so the customers had to use the web interface to get a new password when they log in. The same goes for address information. OpenCart version 1.5.1 was used.
Looking at the database tables used by OpenCart, there is one which is used for important customer data (table cutomer) that needs to be populated.
mysql> DESCRIBE customer; +-------------------+-------------+------+-----+---------------------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------------+-------------+------+-----+---------------------+----------------+ | customer_id | int(11) | NO | PRI | NULL | auto_increment | | store_id | int(11) | NO | | 0 | | | firstname | varchar(32) | NO | | | | | lastname | varchar(32) | NO | | | | | email | varchar(96) | NO | | | | | telephone | varchar(32) | NO | | | | | fax | varchar(32) | NO | | | | | password | varchar(40) | NO | | | | | cart | text | YES | | NULL | | | wishlist | text | YES | | NULL | | | newsletter | tinyint(1) | NO | | 0 | | | address_id | int(11) | NO | | 0 | | | customer_group_id | int(11) | NO | | NULL | | | ip | varchar(15) | NO | | 0 | | | status | tinyint(1) | NO | | NULL | | | approved | tinyint(1) | NO | | NULL | | | date_added | datetime | NO | | 0000-00-00 00:00:00 | | +-------------------+-------------+------+-----+---------------------+----------------+
The password field was set to a dummy value so the customer needed to reset it when logging in, there is an existing web interface for that functionality (to get a new password via email). The SQL statement needed to construct entries for one dummy customer follows. It seem to be too expensive to buy a module extension to OpenCart for, e.g. 25 dollars, to import data on this simple format.
INSERT INTO customer(
firstname,lastname,email,
telephone,fax,password,newsletter,status,approved,date_added)
VALUES(
'Peter','Jansson','peter.jansson@the.net',
'+46-(0)18-4951199','','dummy',1,1,1,NOW());
0 kommentarer:
Post a Comment