You are here

function amazon_item_lookup_from_web in Amazon Product Advertisement API 7

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

Use Amazon API to look up an array of ASINs.

Parameters

$item_ids: Array of ASIN strings to look up.

Return value

array Array of cleaned XML structures keyed by ASIN.

3 calls to amazon_item_lookup_from_web()
amazon_cron in ./amazon.module
amazon_item_lookup in ./amazon.module
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.
amazon_test_form_validate in ./amazon.admin.inc

File

./amazon.module, line 381

Code

function amazon_item_lookup_from_web($item_ids = array(), $locale = NULL) {
  $amazon_limit = 10;

  // Amazon will accept no more than 10 items
  $asins = array();
  $results = array();
  $item_ids = array_filter($item_ids);

  // Remove any empty items.
  foreach ($item_ids as $asin) {
    if (!empty($asin)) {
      $asins[] = $asin;
      if (count($asins) >= $amazon_limit || count($asins) == count($item_ids)) {
        $results += _amazon_item_batch_lookup_from_web($asins, $locale);
        $asins = array();
      }
    }
  }
  return $results;
}