Upgrade Your Drupal Skills

We trained 1,000+ Drupal Developers over the last decade.

See Advanced Courses NAH, I know Enough

Amazon associate tools for Drupal 6...sort of

Parent Feed: 

Check the previous three posts and you'll see the basic functionality for Amazon Associate Tools is now functional here on Code.

Searching for Books, DVDs and Music is supported; other product types would be added by customizing the include file for the Amazon site you are querying just like last version. Bulk imports are next. Blocks come after that; I believe I'll get both squared away this weekend.

Some folks complained the detail page url didn't wind up crediting their account when folks purchased things. Rather than using the detail page url to like to a product, I used a "approved do-it-yourself" link.

I do have shortcomings to overcome. Notice the Amazon.com search page is not integrated into the site search functionality. It seems to do that you have to actually use the Search API. Maybe I screwed the menu definition when I tried it. Also, the database tables as slightly different...upgradable, but no upgrade yet.

And I have additions to make, in particular a shopping cart. I hesistate on this one because I have no idea if I can use existing Drupal ecommerce shopping carts. I have no idea how the ecommerce modules work. I asked a couple years back when I wrote the first version of this thing. Never got an answer, and to be honest the whole thing looks massive enough that figuring out where to insert some code (if one even can) would slow me down a lot.

I also want to do some sort of wizard thing because I'm targeting setting up a store. That means category pages, author pages and such like. I can wrangle it by hand, of course, but I think a good wizard can turn this into a fairly successful "long tail" product.

So that's where it's at so far. Tomorrow I'll repost my old Drupal 5 modules here other than an AAT page.  I'll likely rename the thing.

LATER: Line 205 of amazon.module (amazon_cron) tried to use db_num_rows() which, of course, doesn't exist in D6. The function ought to look like:

function amazon_cron() {
  // get 10 ASINs whose prices haven't been updated for a week
  $stale_price_date = date('Y-m-d', time() - 604800); //604800 is a week of seconds
  $stale_records = db_query_range("SELECT asin FROM {amazonitem} WHERE pricedate <= '%s' ORDER BY pricedate", $stale_price_date, 0, 10);
  // get the Amazon records for each of them
  while ($stale_asin = db_fetch_object($stale_records)) {
    $asin_to_refresh[] = $stale_asin->asin;
  }
  if (count($asin_to_refresh)) {
    $asinlist = implode(',', $asin_to_refresh);
    $asin_update = _amazon_product_data_from_Amazon($asinlist);
    // update their amazonitem records
    if (count($asin_update) > 0) {
      foreach($asin_update as $asin_data) {
        _refresh_amazonitem_data($asin_data);
      }
    }
  }
}

AttachmentSize
14.39 KB
Author: 
RSS Tags: 
Original Post: 

About Drupal Sun

Drupal Sun is an Evolving Web project. It allows you to:

  • Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
  • Facet based on tags, author, or feed
  • Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
  • View the entire article text inline, or in the context of the site where it was created

See the blog post at Evolving Web

Evolving Web