Page 1 of 1

importing customers

Posted: Wed Oct 28, 2015 11:09 am
by mike92117
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?

Re: importing customers

Posted: Sun Nov 22, 2015 5:46 pm
by mike92117
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);

Re: importing customers

Posted: Mon Nov 23, 2015 11:12 am
by Katie
Thank you so much for posting this! Good stuff :)