You are here

function asin_feeds_set_target in Amazon Product Advertisement API 6

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

Callback for mapping. Here is where the actual mapping happens.

When the callback is invoked, $target contains the name of the field the user has decided to map to and $value contains the value of the feed item element the user has picked as a source.

1 string reference to 'asin_feeds_set_target'
asin_feeds_node_processor_targets_alter in asin/asin.module
Implementation of hook_feeds_node_processor_targets_alter().

File

asin/asin.module, line 493
Defines a field type for referencing an Amazon product.

Code

function asin_feeds_set_target($node, $target, $value) {
  $field = isset($node->{$target}) ? $node->{$target} : array();

  // Handle multiple value fields.
  if (is_array($value)) {
    $i = 0;
    foreach ($value as $v) {
      if (!is_array($v) && !is_object($v)) {
        $field[$i]['asin'] = $v;
      }
      $i++;
    }
  }
  else {
    $field[0]['asin'] = $value;
  }
  $node->{$target} = $field;
}