You are here

function amazon_update_7107 in Amazon Product Advertisement API 7

Same name and namespace in other branches
  1. 7.2 amazon.install \amazon_update_7107()

Migrate existing amazon variables to new variable format.

File

./amazon.install, line 200
Install, update and uninstall functions for the amazon module.

Code

function amazon_update_7107() {
  $amazon_locale = variable_get('amazon_locale', 'US');

  // Update the locale setting variable
  variable_set('amazon_default_locale', $amazon_locale);

  // Load locale data
  require_once drupal_get_path('module', 'amazon') . '/includes/amazon.locales.inc';
  $locales = _amazon_load_locales();

  // Set up default values for each locale to the Drupal Association ID for that locale (if available)
  foreach ($locales as $locale => $data) {
    variable_set('amazon_locale_' . $locale . '_associate_id', $data['da_associate_id']);
  }

  // Update the associate ID for the default locale to the value previously set
  $custom_assoc_id = variable_get('amazon_custom_associate_id', '');
  if ($custom_assoc_id) {
    variable_set('amazon_locale_' . $amazon_locale . '_associate_id', $custom_assoc_id);
  }

  // Remove depricated variables.
  variable_del('amazon_locale');
  variable_del('amazon_custom_associate_id');
  variable_del('amazon_associate_setting');
}