+ Reply to Thread
Results 1 to 13 of 13

 

Thread: Importing Product Datafeed - PHP Help Needed!

  1. #1
    Registered User

    Status
    Offline
    Join Date
    Oct 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts


    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

  2. #2
    Spartacus's Avatar
    [yet-to-be] freed slave

    Status
    Offline
    Join Date
    Sep 2006
    Location
    Sheffield
    Posts
    316
    Thanks
    6
    Thanked 5 Times in 5 Posts
    I think what you are trying to so is probably impossible. How could you ever know what commas are delimiters and what aren't?
    Here endeth the post

    http://www.tenuouslinks.co.uk (Social networking for the anti-social )

  3. #3
    Travel Squared

    Status
    Offline
    Join Date
    Sep 2006
    Location
    Cambridge
    Posts
    870
    Thanks
    114
    Thanked 66 Times in 42 Posts
    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

  4. #4
    Registered User

    Status
    Offline
    Join Date
    Oct 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?

  5. #5
    tbp
    Registered User

    Status
    Offline
    Join Date
    Dec 2006
    Posts
    1,998
    Thanks
    0
    Thanked 22 Times in 22 Posts
    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.

  6. #6
    Travel Squared

    Status
    Offline
    Join Date
    Sep 2006
    Location
    Cambridge
    Posts
    870
    Thanks
    114
    Thanked 66 Times in 42 Posts
    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

  7. #7
    Super Member

    Status
    Offline
    Join Date
    Aug 2003
    Location
    Costa Del Sheffield
    Posts
    2,838
    Thanks
    5
    Thanked 18 Times in 14 Posts
    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

  8. #8
    Registered User

    Status
    Offline
    Join Date
    Aug 2003
    Location
    Colchester
    Posts
    231
    Thanks
    30
    Thanked 17 Times in 16 Posts
    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

  9. #9
    Registered User

    Status
    Offline
    Join Date
    Oct 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  10. #10
    Registered User

    Status
    Offline
    Join Date
    Oct 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  11. #11
    Registered User

    Status
    Offline
    Join Date
    Jul 2004
    Location
    Surrey
    Posts
    983
    Thanks
    10
    Thanked 14 Times in 10 Posts
    Generally, if you're using files which have the delimiter in the actual fields, (e.g. a comma in this case) those fields should have quotes round them so they can be ignored.

    <plug>
    The Affilistore tutorial I'm doing uses a file delimited with semicolons, and you'll see there are also semicolons in the product titles. The file importer in Affilistore knows to ignore these as there are quote marks round the whole product field.
    Check it out here
    </p>

    This can still allow cock-ups, particularly in postal address data where you can get stuff like "Dunworkin", 2 The Street all in one field and the poor importer doesn't know whether it's coming or going. Thank god I stopped working in direct mail 8 years ago!

    For flat files, I usually find that tab delimited is most reliable and easiest to handle as it's not possible to type a tab into an online form.

  12. #12
    Registered User

    Status
    Offline
    Join Date
    Dec 2008
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Subject: Building an Affiliate Store Was Never so Easy!
    If you ever thought building an affiliate store was just too hard then the patented Datafeedr "Click & Create" system is just what you've been waiting for!

    Build Unlimited Affiliate Datafeed eCommerce Stores | datafeedr.com

  13. #13
    Registered User

    Status
    Offline
    Join Date
    Dec 2008
    Posts
    11
    Thanks
    1
    Thanked 1 Time in 1 Post
    Hi Nick,

    We had recently built a product catalog / affiliate store website. We had faced the same problem. Try to get the xml feeds if possible or get the pipe seperated csv feeds.

    This is website that we have built www.buy-products-online.co.uk

    If you have any problems then do let me know and I will see what I can do for you

    Cheers,

    Nick
    Nick
    WEBWORX | Web Desgin & Development, SEO, Content Writing | www.webworxindia.com

+ Reply to Thread


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 4
    Last Post: 17-03-07, 04:50 PM
  2. Product Managers Required!
    By AndyMN in forum Affiliate Marketing Lounge
    Replies: 3
    Last Post: 20-05-06, 12:25 AM
  3. Use vb.net or php to build product feed site?
    By accelerator in forum Programming
    Replies: 2
    Last Post: 18-01-05, 03:32 PM
  4. eDirectory Affiliates Newsletter
    By Pistol101 in forum Affiliate Future
    Replies: 0
    Last Post: 22-07-03, 09:48 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
To Top

Content Relevant URLs by vBSEO 3.5.0 RC2