You are here

function template_preprocess_amazon_inline in Amazon Product Advertisement API 8.2

Prepares variables for the amazon-inline Twig template.

Parameters

array $variables: Array of variables including the results of the APA API call.

File

./amazon.module, line 66
Provides the easy integration of the Amazon Product Advertising API.

Code

function template_preprocess_amazon_inline(&$variables) {

  // Only use the first result since we only build one link.
  $variables['title'] = '';
  $variables['url'] = '';
  $variables['item'] = [];
  if (!empty($variables['results'][0])) {
    $item = $variables['results'][0];
    $variables['title'] = $item->ItemAttributes->Title;
    $variables['url'] = $item->DetailPageURL;
    $variables['item'] = $item;
  }
}