function amazon_cron in Amazon Product Advertisement API 7.2        
                          
                  
                        Same name and namespace in other branches
- 6 amazon.module \amazon_cron()
 - 7 amazon.module \amazon_cron()
 
 
File
 
   - ./amazon.module, line 1016
 
  
Code
function amazon_cron() {
  
  $amazon_data = amazon_data_cache();
  $locales = $amazon_data['locales'];
  foreach ($locales as $locale => $item) {
    if (variable_get('amazon_locale_' . $locale . '_associate_id', '')) {
      
      $needs_update_time = REQUEST_TIME - variable_get('amazon_refresh_schedule', 86400);
      $result = db_select('amazon_item', NULL, array(
        'fetch' => PDO::FETCH_ASSOC,
      ))
        ->fields('amazon_item', array(
        'asin',
      ))
        ->condition('timestamp', $needs_update_time, '<')
        ->condition('locale', $locale, '=')
        ->orderBy('timestamp', 'ASC')
        ->range(0, variable_get('amazon_refresh_cron_limit', 50))
        ->execute();
      $asins = $result
        ->FetchCol();
      if (!empty($asins)) {
        if ($items = amazon_item_lookup_from_web($asins, $locale)) {
          foreach ($items as $item) {
            amazon_item_insert($item);
          }
          watchdog('amazon', 'Amazon items were updated.');
        }
        else {
          watchdog('amazon', 'Amazon items could not be updated.');
        }
      }
    }
  }
}