importing customers

For general questions and discussions specific to the AbleCommerce GOLD ASP.Net shopping cart software.
Post Reply
mike92117
Lieutenant (LT)
Lieutenant (LT)
Posts: 64
Joined: Sat Nov 07, 2009 6:41 pm

importing customers

Post by mike92117 » Wed Oct 28, 2015 11:09 am

I’m trying to solve this problem: I have a customer list from another e-commerce app and need to import the customer data into GOLD. While it looks trivial to do direct database access (handful of user tables + ac_Addresses, possibly wishlists, etc.), I was wondering if there is a safe means to do this through some api calls? If not, is there a recommended approach? I would certainly need some sort of API function to correctly store a password in the ac_UserPasswords table).

I'm thinking of a console app (run once) that would read through each customer, add the customer info (ac_User), passwords (ac_UserPasswords), groups (ac_UserGroups) , addresses (ac_Addresses).

Any suggestions or guidance you can provide?

mike92117
Lieutenant (LT)
Lieutenant (LT)
Posts: 64
Joined: Sat Nov 07, 2009 6:41 pm

Re: importing customers

Post by mike92117 » Sun Nov 22, 2015 5:46 pm

I solved the problem, which turns out to be mostly simple. For anyone that is curious, I wrote a console app to insert a customer and then any customer addresses and then just loop through each customer in turn.

You need to reference NHibernate, NHibernate.Caches.SysCache, System.Web and of course CommerceBuilder. And you need to have log4net.config and nhibernate.config in the project.

Customers can be created by passing in email and password to this method:

Code: Select all

user = UserDataSource.CreateUser(c.EMAIL.ToLower(), c.PASS);
We now have a user instance (with id field) and can create a new Address instance, populate the various fields

Code: Select all

Address addr = new Address(user,...);
addr.User = user;
and then finally:

Code: Select all

AddressDataSource.Insert(address);

User avatar
Katie
AbleCommerce Admin
AbleCommerce Admin
Posts: 2651
Joined: Tue Dec 02, 2003 1:54 am
Contact:

Re: importing customers

Post by Katie » Mon Nov 23, 2015 11:12 am

Thank you so much for posting this! Good stuff :)
Thank you for choosing AbleCommerce!

http://help.ablecommerce.com - product support
http://wiki.ablecommerce.com - developer support

Post Reply