You are here

function amazon_expire_items in Amazon Product Advertisement API 7

Same name and namespace in other branches
  1. 7.2 amazon.module \amazon_expire_items()

Allows expiration of items in the amazon_item table. Items can be expired by productgroup type, specifically by asin, or all items. If no parameters are specified, all items will be expired.

Parameters

$asins: array of ASINs to expire

$types: array of productgroup types to expire

2 calls to amazon_expire_items()
amazon_flush_caches in ./amazon.module
Implements hook_flush_caches().
amazon_settings_form_validate in ./amazon.admin.inc
Validate the keys and trim whitespace.

File

./amazon.module, line 941

Code

function amazon_expire_items(array $asins = array(), array $types = array()) {
  $query = db_update('amazon_item')
    ->fields(array(
    'timestamp' => 0,
  ));
  if (!empty($asins)) {
    $query
      ->condition('asin', $asins, 'IN');
  }
  if (!empty($types)) {
    foreach ($types as $key => $value) {
      $types[$key] = strtolower($value);
    }
    $query
      ->condition('lower(productgroup)', $types, 'IN');
  }
  $updated = $query
    ->execute();
  $update_msg = format_plural($updated, '1 Amazon Item has been expired', '@count Amazon Items have been expired');
  watchdog('amazon', $update_msg, NULL, WATCHDOG_INFO, NULL);
}