How to write custom CSV import routine

A forum where issues related to the DataPort utility can be discussed.
Post Reply
User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

How to write custom CSV import routine

Post by mazhar » Fri Feb 20, 2009 6:44 am

You can write your own import routines to import the CSV data directly from the admin pages. I thought it would be helpful for the community to have some sample of custom CSV import routine. This sample is about how to import users from a CSV file. This is just a sample and provides a basic over view of the user import. It will only import the data for fields that are available with user object. For example the First and last name fields are available in address class so it will not import that information. Obviously that could be done but that will be a complected task and it would be better to keep the sample simple. The sample targets advance users who may want to import their custom CSV information.
Image

You can download the sample from this thread
viewtopic.php?f=47&t=9720

IntraSpek
Ensign (ENS)
Ensign (ENS)
Posts: 1
Joined: Thu Feb 26, 2009 6:03 am

Re: How to write custom CSV import routine

Post by IntraSpek » Thu Feb 26, 2009 7:06 am

Hi Mazhar-

We are needing to create some custom process for uploading CSV or XML data received from our call center, into the Able Cart. The call center will be taking phone orders for one or more products of our products using their call system, not our cart. At the end of each day, we will get a file from them (the call center) and will we need to upload the data into our system. This is essentially the customer info, what they are ordering, and the payment information. Your solution of uploading directly from the admin pages is great, but I'm still not sure how to handle the CC info. Do you have any recommendations?

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: How to write custom CSV import routine

Post by mazhar » Thu Feb 26, 2009 8:07 am

In fact after reading the CSV headers you need to use the AbleCommerce objects to import that data. So if you are trying to import some order then it means you have to put some code to map CSV fields on order object and import them. For example check the following thread where credit card information is imported for orders
viewtopic.php?f=42&t=9839

Niraj8428
Ensign (ENS)
Ensign (ENS)
Posts: 19
Joined: Fri Feb 20, 2009 9:13 am

Re: How to write custom CSV import routine

Post by Niraj8428 » Mon Mar 02, 2009 9:22 am

Hi Mazhar in your sample application to import User details how to import FirstName and LastName fields? as you said "..First and last name fields are available in address class so it will not import that information." because our ultimate goal is to import Order details but we are facing some issues not sure values for what all fields we shall give in CSV? if we give fields for all columns then will it automatically consider them as collection? like if we give values of all required fields of Payment then will it consider it as Orders Payments details? it means I am talking about your code.

Can you please tell us what all columns we shall if we want to import Order details?

any help will be highly appreciated.

Thanks,
Niraj Parikh

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: How to write custom CSV import routine

Post by mazhar » Mon Mar 02, 2009 9:44 am

Read the CSV fields for orders import supported by DataPort form here
http://wiki.ablecommerce.com/index.php/ ... rt_Utility

Niraj8428
Ensign (ENS)
Ensign (ENS)
Posts: 19
Joined: Fri Feb 20, 2009 9:13 am

Re: How to write custom CSV import routine

Post by Niraj8428 » Mon Mar 02, 2009 11:00 pm

that didn't work, in your case how to set values for First Name and Last Name fields from CSV for User details? as they are not fields of User table.

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: How to write custom CSV import routine

Post by mazhar » Tue Mar 03, 2009 11:33 am

Set them on User.PrimaryAddress
You can download the API documentation from here
ftp://ftp.ablecommerce.com/evals/Commer ... 7_Help.zip

User avatar
robreil
Captain (CAPT)
Captain (CAPT)
Posts: 340
Joined: Fri Jun 10, 2005 1:22 pm
Location: Kennesaw, Ga. USA
Contact:

Re: How to write custom CSV import routine

Post by robreil » Sun Mar 08, 2009 1:42 pm

As stated in viewtopic.php?f=61&t=9973 I have a Able5.5CFMX cart with MySQL 4.1 DB with some custom fields put in the Products table.

When migrating from 5.5 to 7.x how will I get all of that data migrated into 7.x.
I have extra tables too but they are static and I can do a table back up as csv, and then an import into the database directly as the Cart does not hit those tables yet..

The extra fields are only pulled from when an email is sent via the cart. namely "Our Notification".

Please advise.

Post Reply