Amazon Module
Contents
- Background Information on Amazon Module and the Amazon Product Advertising API
- Installation and Configuration
- Using the Amazon ASIN CCK type
- Using Views with Amazon
- Using the Amazon Examples Sample View and CCK type
- Using the Filters Provided with the Amazon Filter Module
- Theming Templates (.tpl.php)
- Amazon Store Module
- Technical Details
Background Information
Amazon.com (and its variants in England, France, Japan, etc.) provides a Product Advertising API which is enormously powerful and provides information about books and many other consumer products. Amazon Module provides that functionality for Drupal using the Product Advertising API.
Each item on Amazon.com has a unique identifier called an ASIN, or Amazon Standard Indentification Number. It's 10 characters long. Note that ASINs for the same item may be different on different versions of Amazon's site (different locales, such as France, Japan, etc.)
To use this module, the ASIN will be the fundamental concept. You can get ASINs to use several ways. You can use the Amazon Search module, you can search Amazon.com, or you can use the Amazon Store module. On any product page on Amazon.com, you will see the ASIN in the "Product Details" section. It is also clearly visible in the page URL.
Installation and Configuration
- Install and enable the modules as usual. Normally, this just means untarring into sites/all/modules and enabling the modules you want on the modules page.
- You must enable the Amazon API module.
- Amazon Field provides the Amazon CCK type.
- Amazon Filter provides a Drupal filter in the form [amazon ASIN thumbnail] that you can use to put Amazon data directly into content in the body of any item.
- Amazon Media provides extended support for books, music, DVDs, and software.
- Amazon Search provides a rudimentary search facility.
- Amazon Examples provides a sample CCK type and view that demonstrate how to use Amazon module with CCK and views. It requires the features module. To turn it on, either enable the module or go to the Features configuration page at admin/build/features and enable it. (When features is turned on, it seems to hide the amazon_examples module, letting you manage it only from within its own interface.)
- Obtain an Amazon AWS account if you do not already have one. Go to http://aws.amazon.com and sign up. Then you'll need to go to the "Security Credentials" page to get your Access Key ID and Secret Access Key. Note: If you already use Amazon AWS and do not want to disclose your keys by configuring them on the site, you can get a new free Amazon AWS account.
- Go to admin/settings/amazon (Administration -> Configuration -> Amazon API) and configure the module with:
- Locale: Which store are you going to use? US? UK? Japan?
- Amazon Referral Settings: Every purchase bought by a referral can get you a commission if you would like. You can set this to the Drupal Association's ID, the module developer's ID, or to your own. To get your own ID, sign up at Amazon's Product Advertising API site.
- Your Amazon keys. Instructions on getting an account if you don't have one are above.
- After configuring, go to the test page (the "test" tab) and enter a valid Amazon ASIN. An example might be 0596515804. Click the submit button and make sure that the system can look up the ASIN. If it succeeds, you're all set!
Using the Amazon ASIN CCK type
Note: If you enable the Amazon Examples module (provided), it provides a preconfigured CCK type which you can experiment with. The following instructions just duplicate that.
The simplest and easiest way to use Amazon information is with a CCK type. If you have enabled the Amazon Examples module, then you already have a CCK type to work with. The following instructions will just duplicate that.
- Create a content type at admin/content/types/add.
- Add a field and set the field type to "Amazon Item".
- Create a node or two of this content type. The ASIN field requires a 10-digit ASIN (Amazon Standard Identification Number) which each product on Amazon's websites provides.
- You should see the product show up in your node. In the content type settings, you can configure the display type for four different presentations.
Using Views with the Amazon CCK Type
Watch the video demonstrating views
You must have "Store Amazon Data Locally" turned on in the "Storage" tab (admin/settings/amazon/storage) or views will not work.
Note: Again, if you enable the Amazon Examples module (provided) it preconfigures a view called Amazon Example View which uses the CCK type "Amazon Example", so you don't have to do anything to try out a view.
There are three ways to use Views with Amazon module:
- Configure a node-type view and just use and configure the Content: ASIN field (or whatever your field is called. This will allow you to present the view with four different basic presentations, but does not allow sophisticated access to the many pieces of information provided with Amazon data.
- Configure a node-type view and create a relationship on the Content: ASIN field (or whatever your field is called. Make the relationship required. You will then have access to many fields and filter options that can be displayed in your view.
- Configure an "Amazon Item" type view. This will let you have access to all Amazon Items cached on your system, with all of the information stored in each. There is no linkage information to the nodes that might use these items.
If you create a relationship on the Content field, you get access to a wide variety of product information. Some of the important items are:
- ASIN
- All Participants (authors, etc.)
- Binding
- Detail Page URL (link to Amazon.com page, or Amazon Store page)
- Invalid ASIN - set to 1 if the ASIN can no longer be looked up on Amazon, but remains in your database.
- List Price
- Manufacturer
- Product Image (configurable for the three sizes Amazon provides)
- Title
You can also use any of the many data items together with the views custom data field to construct a more sophisticated link, image, etc. There is an example of this in the examples views.
Using the Amazon Examples CCK type and View
Amazon module now ships with a feature which provides a sample content type and a sample view. Here's a quickstart on how to use it:
- Download (if necessary) and enable the features module
- Enable the features module at admin/build/modules
- Go to the features UI at admin/build/features and enable the "Amazon Examples" feature.
- You now have a CCK type called "Amazon Example".
- Create a couple of instances of "Amazon Example" by going to node/add/amazon_example. Here are a couple of ASINs you can use: 1430209895 and 0470429038. Your nodes should show a thumbnail and the title of the item at this point.
- Go to the Views interface at admin/build/views and you'll see an "Amazon Example View". Click "edit" and you can look at and modify and experiment with it. The two nodes you created should show up there.
Using the Filters Provided with Amazon Filter Module
First, enable the Amazon Filter module at Admin->Site Building->Modules.
Now go to Administer -> Site configuration -> Input formats. Switch on the Amazon filter for each input format you want to process Amazon tags.
Now you can use many filters in the format [amazon <ASIN> <action>] in any text field that is processed by the filter.
Some filters just present a simple view of the product:
- [amazon 0596515804 thumbnail] presents a thumbnail and the item title.
- [amazon 0596515804 full] presents a larger image and more information.
[amazon 0596515804 inline] just puts the item title linked to the Amazon page inline.
In addition, many, many other options are available, providing access to much of the data available:
- [amazon 0596515804 asin]
- [amazon 0596515804 title]
- [amazon 0596515804 detailpageurl]
- [amazon 0596515804 salesrank]
- [amazon 0596515804 publisher]
- [amazon 0596515804 manufacturer]
- [amazon 0596515804 studio]
- [amazon 0596515804 label]
- [amazon 0596515804 binding]
- [amazon 0596515804 listpriceamount]
- [amazon 0596515804 listpricecurrencycode]
- [amazon 0596515804 listpriceformattedprice]
- [amazon 0596515804 productgroup]
- [amazon 0596515804 producttypename]
- [amazon 0596515804 invalid_asin] (set to 1 if this ASIN is no longer valid on Amazon)
- [amazon 0596515804 deweydecimalnumber]
- [amazon 0596515804 edition]
- [amazon 0596515804 numberofpages]
- [amazon 0596515804 publicationdate]
- [amazon 0596515804 type]
- [amazon 0596515804 releaseyear]
- [amazon 0596515804 publicationyear]
- [amazon 0596515804 smallimage]
- [amazon 0596515804 smallimageurl]
- [amazon 0596515804 smallimageheight]
- [amazon 0596515804 smallimagewidth]
- [amazon 0596515804 mediumimage]
- [amazon 0596515804 mediumimageurl]
- [amazon 0596515804 mediumimageheight]
- [amazon 0596515804 mediumimagewidth]
- [amazon 0596515804 largeimage]
- [amazon 0596515804 largeimageurl]
- [amazon 0596515804 largeimageheight]
- [amazon 0596515804 largeimagewidth]
Theming Templates (.tpl.php files)
Amazon module provides many .tpl.php files which can be copied to your theme and altered to change the behavior and presentation of your system. See the Drupal Theming Guide for details about how this works.
- amazon_inline_item.tpl.php changes the 'inline' presentation.
- amazon-item-detail.tpl.php is used to theme most of the filter detail items, such as publicationdate, etc.
- amazon-item-details.tpl.php is used to present item details in the "full" presentation.
- amazon-item-thumbnail.tpl.php presents the 'thumbnail' presentation.
- amazon-item.tpl.php is the default item presentation.
- amazon-item-book-details.tpl.php (in amazon_media)
- amazon-item-dvd-details.tpl.php (in amazon_media)
- amazon-item-software-details.tpl.php (in amazon_media)
- amazon-item-video-games-details.tpl.php (in amazon_media)
In addition, the row-item template for views is provided and can be overridden. (amazon-views-view-row-item.tpl.php).
Amazon Store Module
If you want to use the Amazon for an actual shopping or browsing experience, you may be interested in the Amazon Store module, which uses Amazon module as a base. Amazon Store has significant integration with Amazon, and if installed, links from Amazon items in your nodes can be configured to point to Amazon Store product detail pages.
- If you want to understand what's going on under the covers, the documentation on Amazon's API is on their site.

Thanks!
Hey, thanks for the documentation. This is a lifesaver!
Wanted to mention that [amazon 0672329166 author] also works... displays the author(s) of book items.
Also, the image height and width filter terms are apparently intended only to display height and width info, not set the image attributes. Am I right?