function asin_feeds_set_target in Amazon Product Advertisement API 7.2
Same name and namespace in other branches
- 6 asin/asin.module \asin_feeds_set_target()
- 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.
See also
my_module_set_target() in feeds.api.php
1 string reference to 'asin_feeds_set_target'
- asin_feeds_processor_targets_alter in asin/
asin.module - Implementation of hook_feeds_node_processor_targets_alter().
File
- asin/
asin.module, line 448 - Defines a field type for referencing an Amazon product.
Code
function asin_feeds_set_target($source, $entity, $target, $value) {
if (!isset($value)) {
return;
}
// Handle non-multiple value fields.
if (!is_array($value)) {
$value = array(
$value,
);
}
// Iterate over all values.
$i = 0;
$info = field_info_field($target);
$field_name = $target;
foreach ($value as $v) {
$field[LANGUAGE_NONE][$i]['asin'] = $v;
if ($info['cardinality'] == 1) {
break;
}
$i++;
}
$entity->{$field_name} = $field;
}