You are here

function amazon_component_gallery_lookup_from_web in Amazon Product Advertisement API 7.2

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.

1 call to amazon_component_gallery_lookup_from_web()
amazon_component_gallery_lookup in amazon_component/amazon_component.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.

File

amazon_component/amazon_component.module, line 246

Code

function amazon_component_gallery_lookup_from_web($item_ids = array(), $locale = NULL) {

  // Function Variables :: Amazon API Request Limit = 10
  $amazon_limit = 10;
  $asins = array();
  $results = array();

  // Filter :: Remove empty items.
  $item_ids = array_filter($item_ids);

  // FOREACH :: Amazon Product ASIN Batch Lookup
  foreach ($item_ids as $asin) {
    if (!empty($asin)) {
      $asins[] = $asin;
      if (count($asins) >= $amazon_limit || count($asins) == count($item_ids)) {
        $results += _amazon_component_batch_lookup_from_web($asins, $locale);
        $asins = array();
      }
    }
  }

  // Return :: Amazon Product API XML Request cleaned via amazon_component_gallery_clean_xml()
  return $results;
}