You are here

function amazon_item_lookup in Amazon Product Advertisement API 7

Same name and namespace in other branches
  1. 6 amazon.module \amazon_item_lookup()
  2. 7.2 amazon.module \amazon_item_lookup()

Look up an item using database or web. The default is to look in the database for existing data, and then to do the web search if that fails. $force_lookup==TRUE forces going to Amazon's API.

Parameters

$item_ids: An array of ASIN strings or a single ASIN as a string.

$force_lookup: If TRUE, skip the database lookup and just go to the Amazon API lookup.

Return value

array Array of "cleaned" XML item descriptions, keyed on ASIN.

4 calls to amazon_item_lookup()
asin_field_formatter_view in asin/asin.module
Implements hook_field_formatter_view().
asin_field_widget_element_validate in asin/asin.module
Widget validation function.
template_preprocess_amazon_views_view_row_item in ./amazon.module
Template helper for theme_amazon_views_view_row_item
_amazon_filter_process_text in amazon_filter/amazon_filter.module
Actual filter processing function - changes [amazon <whatever>] in text.

File

./amazon.module, line 351

Code

function amazon_item_lookup($item_ids = array(), $force_lookup = FALSE, $locale = NULL) {
  if (empty($item_ids)) {
    return array();
  }
  if (is_string($item_ids)) {
    $item_ids = array(
      $item_ids,
    );
  }
  $items = array();
  if (!$force_lookup) {
    $items = amazon_item_lookup_from_db($item_ids);
  }
  $items_to_fetch = array();
  foreach ($item_ids as $item_id) {
    if (!isset($items[$item_id])) {
      $items_to_fetch[] = $item_id;
    }
  }
  $items_from_web = amazon_item_lookup_from_web($items_to_fetch, $locale);
  $full_set = $items + $items_from_web;
  return $full_set;
}