You are here

function _amazon_component_batch_lookup_from_web in Amazon Product Advertisement API 7.2

Get 10 or less items from the AWS web service. AWS allows ONLY 10 items, See http://docs.amazonwebservices.com/AWSECommerceService/latest/DG/index.ht....

Parameters

$item_ids: Array of ASINs to be looked up.

Return value

Array of ASIN data structures keyed by ASIN.

1 call to _amazon_component_batch_lookup_from_web()
amazon_component_gallery_lookup_from_web in amazon_component/amazon_component.module
Use Amazon API to look up an array of ASINs.

File

amazon_component/amazon_component.module, line 279

Code

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

  //Function Variables
  $items = array();

  // IF :: Check Item ID's Existence
  if (!empty($item_ids)) {
    $params = array(
      'ItemId' => implode(',', $item_ids),
      'ResponseGroup' => amazon_get_response_groups(),
    );

    // Result :: Raw Amazon Product API XML request
    $results = amazon_http_request('ItemLookup', $params, $locale);

    // IF :: Check for errors and set watchdog message
    if (!empty($results->Items->Request->Errors)) {
      _amazon_item_batch_lookup_from_web_errors($results->Items->Request->Errors);
    }

    // IF :: Check Item Existence
    // LOOP :: Convert XML to Gallery(s) + Insert Gallery(s) into Database
    if (!empty($results->Items->Item)) {
      foreach ($results->Items->Item as $xml) {
        $item = amazon_component_gallery_clean_xml($xml);

        //amazon_component_gallery_insert($item); /* TODO :: Create function so it works! */

        //$items["{$item['asin']}"] = $item;
        $items[(string) $xml->ASIN] = $item;
      }
    }
    return $items;
  }
  return array();
}