Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

My solution to product imports using column names

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 09-26-2005, 07:10 AM
 
Don L Don L is offline
 

Member
  
Join Date: Sep 2005
Posts: 27
 

Default My solution to product imports using column names

My Problem:
My product database has some extra fields not used by x-cart, and lacks some fields that are used by x-cart. The "Get column names from the first row of the CSV file" option was not working for me and I received an error complaining about the format of my field name header. It's not convenient for me to create a separate feed just for xcart because I have other needs for the feed, and prefer working with the same file for all applications.

My feed's layout (\t used to indicate a tab; truncated to simplify example):
product \t desc \t productcode \t field_not_used_by_xcart \t price

X-cart's import facility seems to be extremely picky, and doesn't like the feed's format. I commented out the section of the code that checks the header for correct column names. I believe their code would require you to have every column included and none extra, which is why it was killing my feed. Since the code is not checking your columns for correctness, it's important that you do so! Here's the code to comment out:

Code:
/* if (!is_array($first_row) || count(array_diff($first_row, $fields_to_compare)) > 0) { # # Error: cvs header error (wrong list of fields) # $top_message["content"] = func_get_langvar_by_name("msg_err_csv_header"); $top_message["type"] = "E"; if ($import_file["uploaded"]) @unlink($import_file["location"]); x_session_unregister("import_file"); func_header_location("import.php"); } */

the /* ... */ pair is how you comment out the code.

Creating the header:
For nulls, don't actually type NULL, just leave a blank field. For example, my header for my example looks like

product \t desc \t productcode \t \t price

Notice I just left an extra tab where my extra field was.

This worked fine for me, but as with all code-hacks, I'd be careful using this on a live site. Test it out on a test install first if you can.
__________________
GetItCheap.com
x-cart v4.0.17

TheNewDonald.com - Internet Marketing Blog
Reply With Quote
  #2  
Old 10-11-2005, 08:09 AM
 
balinor balinor is offline
 

Veteran
  
Join Date: Oct 2003
Location: Connecticut, USA
Posts: 30,253
 

Default

Moving to Custom Mods...or else this will just get lost in the Product Management forum. Thanks for contributing!
__________________
Padraic Ryan
Ryan Design Studio
Professional E-Commerce Development
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 02:06 AM.

   

 
X-Cart forums © 2001-2020