Affiliate Marketing
Forum Search

Reply
 
LinkBack Thread Tools Display Modes

  #1 (permalink)  
Old 24-10-07
Registered User
 
Join Date: Oct 2007
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Himore is infamous around these parts
  Importing Product Datafeed - PHP Help Needed!

Hi.

I'm writing a script to import a vendor's datafeed from AffiliateWindow into a MySQL db so I can then show the products on my website.

I admit I'm no PHP expert, but I've been trying to break the CSV file into parts using the 'explode' function. This was working fine with some small CSV test files I had produced, but when I tried it on the actual vendor datafeed the data was imported incorrectly.

After a couple of minutes scratching my head, I noticed that some of the description fields in the datafeed were very lengthy and actually contained commas within the description. The explode function was therefore seeing each comma as a delimiter (as it should), but I don't want to break up the description because it should be completely in a field of it's own.

Does that make sense? I'd appreciate some advice on how to get over this hurdle. As I say, I'm only a novice when it comes to PHP so the answer may well be obvious, but I'll take the flak and any comments about being 'stoopid' if only someone could help me.

thanks in advance.

Nick
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 24-10-07
Spartacus's Avatar
[yet-to-be] freed slave
 
Join Date: Sep 2006
Location: Sheffield
Posts: 209
Thanks: 0
Thanked 1 Time in 1 Post
Spartacus is an unknown quantity at this point
  Re: Importing Product Datafeed - PHP Help Needed!

I think what you are trying to so is probably impossible. How could you ever know what commas are delimiters and what aren't?
__________________
http://www.tenuouslinks.co.uk (No SEO required)
http://www.rentagaff.co.uk (Search2Let)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 24-10-07
Travel Pixel's Avatar
Travel Squared
 
Join Date: Sep 2006
Posts: 393
Thanks: 2
Thanked 5 Times in 3 Posts
Travel Pixel seems to know their stuff
  Re: Importing Product Datafeed - PHP Help Needed!

can u get the feed in another format aside from .csv?

how about tab seperated or pipe?

that would solve your dilemma.
__________________
Affiliate Citizen
Holiday Reviews & Travel Deals || Travel Merchants: Please contact me if you have special offers or codes
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 24-10-07
Registered User
 
Join Date: Oct 2007
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Himore is infamous around these parts
  Re: Importing Product Datafeed - PHP Help Needed!

Quote:
Originally Posted by Spartacus View Post
I think what you are trying to so is probably impossible. How could you ever know what commas are delimiters and what aren't?
Thanks for the reply. But if it's impossible, then how do the thousands of affiliate stores using merchant feeds manage to do it?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #5 (permalink)  
Old 24-10-07
tbp tbp is offline
Registered User
 
Join Date: Dec 2006
Posts: 1,999
Thanks: 0
Thanked 18 Times in 18 Posts
tbp is an unknown quantity at this point
  Re: Importing Product Datafeed - PHP Help Needed!

If you have PHP 5, the easiest way to parse Affiliate Window feeds is to download the feed as XML. You can then use the simple PHP extension which makes parsing the file really easy!
EG:

PHP Code:
<?php 
$xml 
simplexml_load_file("/home/user_dir/public_html/test/awProductFeed.xml"); 

foreach(
$xml->merch->prod as $product){ 
    echo 
"Name: " $product->name "<br>"
    echo 
"AW Cat ID: " $product->cat->awCatId "<br>"
    echo 
"Brand: " $product->brand "<br>"
    echo 
"AW Link: " $product->awLink "<br>"
    echo 
"Delivery Cost: " $product->delCost "<br>"
    echo 
"Price: " $product->price->search "<br>"
    echo 
"--------------------------" "<br>"

?>
The above code will print out some fields for each product in the XML file. You can easily update it to update or insert into the database.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 24-10-07
Travel Pixel's Avatar
Travel Squared
 
Join Date: Sep 2006
Posts: 393
Thanks: 2
Thanked 5 Times in 3 Posts
Travel Pixel seems to know their stuff
  Re: Importing Product Datafeed - PHP Help Needed!

ah sorry i just noticed you are using affiliatewindow.

they supply feeds in different formats. Use either a pipe separated one and explode by the '|' character or use a tab seperated one and explode by ' \t '.

Easy! Hope that solves that problem.

Dave
__________________
Affiliate Citizen
Holiday Reviews & Travel Deals || Travel Merchants: Please contact me if you have special offers or codes
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 24-10-07
morleymouse's Avatar
Super Member
 
Join Date: Aug 2003
Location: Costa Del Sheffield
Posts: 2,752
Thanks: 3
Thanked 10 Times in 6 Posts
morleymouse is an unknown quantity at this point
  Re: Importing Product Datafeed - PHP Help Needed!

or switch from explode to fget csv - PHP: fgetcsv - Manual
__________________
Dan Morley
Alpharooms.com
daniel at alpharooms dot com - Hotels, Flights, Airport Transfers, Care Hire + More! sign up
My Blog | Cheap Holidays
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #8 (permalink)  
Old 24-10-07
Registered User
 
Join Date: Aug 2003
Location: Colchester
Posts: 113
Thanks: 0
Thanked 0 Times in 0 Posts
gerry180 is an unknown quantity at this point
  Re: Importing Product Datafeed - PHP Help Needed!

Nick

You can also populate your datafeed table using the LOAD DATA statement. This is very fast at loading data.

I use the data feeds delimited by Tab not comma.

The following extract uses Affiliate window's 1.2 data format that has lots of extra (usually empty) fields

Code:
LOAD DATA LOCAL INFILE 'C:/data/files/aw/datafeed.txt' INTO TABLE aw_feeds FIELDS TERMINATED BY '\t' optionally 
enclosed by '"' LINES TERMINATED BY '\n' IGNORE 1 LINES (`merchant_id`,`merchant_name`,`aw_product_id`,`product_id`,
`upc`,`ean`,`mpn`,`isbn`,`model_number`,`product_name`,
`description`,`specifications`,`promotional_text`,
`merchant_category`,`category_id`,`category_name`,
`language`,`brand_name`,`deep_link`,`thumb_url`,`image_url`,
`aw_deep_link`,`aw_thumb_url`,`aw_image_url`,`delivery_time`,
`valid_from`,`valid_to`,`currency`,`search_price`,`store_price`,
`rrp_price`,`display_price`,`delivery_cost`,`web_offer`,`pre_order`,
`in_stock`,`stock_quantity`,`is_for_sale`,`warranty`,`condition`,
`product_type`,`parent_product_id`,`commission_group`,`type`);
Gerry
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 24-10-07
Registered User
 
Join Date: Oct 2007
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Himore is infamous around these parts
  Re: Importing Product Datafeed - PHP Help Needed!

Wow! Thanks to everyone who replied, and so quickly!

Looks like I have a few options to try out. I'll see how I get on and post back once I've done it.

Thanks again to everyone. I'm new to this forum, but it's already one of the most helpful I've found.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 30-10-07
Registered User
 
Join Date: Oct 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
devlin1979 is an unknown quantity at this point
  Re: Importing Product Datafeed - PHP Help Needed!

just seen this, if it's AffiliateWindow you're using then use the API that AW provides. http://www.affiliatewindow.com/affil...ervice_api.pdf that is what i'm using, and i can import the results directly into a table on my MySQL database
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #11 (permalink)  
Old 30-10-07
Super Moderator
 
Join Date: Jul 2004
Location: Surrey
Posts: 871
Thanks: 4
Th