You are here

function _amazon_load_child_data in Amazon Product Advertisement API 7.2

Same name and namespace in other branches
  1. 6 amazon.module \_amazon_load_child_data()
  2. 7 amazon.module \_amazon_load_child_data()

Load participant, image, editorial_review data into database.

Parameters

$item: Amazon data structure.

1 call to _amazon_load_child_data()
amazon_item_lookup_from_db in ./amazon.module
Look up ASINs in database and return arrays of information keyed by ASIN.

File

./amazon.module, line 591

Code

function _amazon_load_child_data(&$item) {
  $result = db_query('SELECT type, participant FROM {amazon_item_participant} WHERE asin = :asin', array(
    ':asin' => $item['asin'],
  ), array(
    'fetch' => PDO::FETCH_ASSOC,
  ));
  foreach ($result as $participant) {

    // unset($participant['asin']);
    $item[$participant['type']][] = $participant['participant'];
    $item['participants'][] = $participant['participant'];
  }
  $result = db_query('SELECT * FROM {amazon_item_image} WHERE asin = :asin', array(
    ':asin' => $item['asin'],
  ), array(
    'fetch' => PDO::FETCH_ASSOC,
  ));
  foreach ($result as $image) {
    unset($image['asin']);
    $item['imagesets'][$image['size']] = $image;
  }

  // Fetch :: Amazon Product Image Galleries
  $result = db_query('SELECT * FROM {amazon_item_image_gallery} WHERE asin = :asin', array(
    ':asin' => $item['asin'],
  ), array(
    'fetch' => PDO::FETCH_ASSOC,
  ));
  foreach ($result as $image) {
    unset($image['asin']);
    $item['imagesets_gallery'][$image['size']][$image['image_order']] = $image;
  }
  $result = db_query('SELECT * FROM {amazon_item_editorial_review} WHERE asin = :asin', array(
    ':asin' => $item['asin'],
  ), array(
    'fetch' => PDO::FETCH_ASSOC,
  ));
  foreach ($result as $review) {
    unset($review['asin']);
    $item['editorialreviews'][] = $review;
  }
}