You are here

function amazon_versions_amazon_item_load in Amazon Product Advertisement API 6

Same name and namespace in other branches
  1. 7.2 amazon_versions/amazon_versions.module \amazon_versions_amazon_item_load()
  2. 7 amazon_versions/amazon_versions.module \amazon_versions_amazon_item_load()

Implementation of hook_amazon_item_load().

File

amazon_versions/amazon_versions.module, line 35

Code

function amazon_versions_amazon_item_load($item) {
  $alternates = array();
  $item_ids = array();
  $result = db_query("SELECT asin, title, binding FROM {amazon_versions} WHERE item = '%s' ORDER BY delta ASC", $item['asin']);
  while ($version = db_fetch_array($result)) {
    $alternates[] = $version;
    $item_ids[] = $version['asin'];
  }
  if (module_exists('amazon_import')) {
    $node_ids = amazon_import_get_product_nodes($item_ids);
    foreach ($alternates as $key => $version) {
      if (!empty($node_ids[$version['asin']])) {
        $alternates[$key]['nid'] = $node_ids[$version['asin']];
      }
    }
  }
  $additions['alternateversions'] = $alternates;
  if (isset($additions)) {
    return $additions;
  }
}