You are here

function _amazon_item_batch_lookup_from_web_errors in Amazon Product Advertisement API 7.2

Same name and namespace in other branches
  1. 7 amazon.module \_amazon_item_batch_lookup_from_web_errors()
2 calls to _amazon_item_batch_lookup_from_web_errors()
_amazon_component_batch_lookup_from_web in amazon_component/amazon_component.module
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....
_amazon_item_batch_lookup_from_web in ./amazon.module
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....

File

./amazon.module, line 529

Code

function _amazon_item_batch_lookup_from_web_errors($errors) {
  foreach ($errors->Error as $error) {
    $code = (string) $error->Code;
    $message = (string) $error->Message;
    $matches = array();

    // Find and extract the failing ASIN, so we can mark it in the db.
    if (preg_match('/^([^ ]+) is not a valid value for ItemId/', $message, $matches)) {
      $error_asin = $matches[1];
      $update_fields = array(
        'invalid_asin' => TRUE,
      );
      try {
        $result = db_update('amazon_item')
          ->fields($update_fields)
          ->condition('asin', $error_asin)
          ->execute();
      } catch (Exception $e) {
        amazon_db_error_watchdog('Failed to update invalid_asin=TRUE on amazon_item.', $e);
      }
    }
    watchdog('amazon', 'Error retrieving Amazon item %code, message: %message.', array(
      '%code' => $code,
      '%message' => $message,
    ), WATCHDOG_WARNING);
  }
}