function uc_feeds_set_target in Ubercart Feed Mappers 7
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 'uc_feeds_set_target'
- uc_feeds_feeds_processor_targets_alter in ./
uc_feeds.module - Implementation of hook_feeds_processor_targets_alter().
File
- ./
uc_feeds.module, line 123
Code
function uc_feeds_set_target($source, $node, $target, $value) {
// We assume single values for all ubercart related entities.
$value = $value[0];
$target_array = explode('_', $target);
if ($target_array[0] != "attribute") {
// For numeric fields, default to 0 if empty
if (in_array($target, array(
'list_price',
'cost',
'sell_price',
'weight',
)) && $value == '') {
$value = 0;
}
$node->{$target} = $value;
}
else {
$key = $target_array[1];
if ($key == 'combinations') {
$data = unserialize($value);
if ($data !== FALSE && is_array($data)) {
$node->uc_feeds['combinations'] = $data;
}
}
else {
$aid = $target_array[2];
$oid = $target_array[3];
// If value is empty, it's not an attribute we want to use
if ($value != '') {
if (!isset($node->uc_feeds['attributes'][$aid])) {
$node->uc_feeds['attributes'][$aid] = new stdClass();
}
if (!isset($node->uc_feeds['attributes'][$aid]->options[$oid])) {
$node->uc_feeds['attributes'][$aid]->options[$oid] = new stdClass();
}
$node->uc_feeds['attributes'][$aid]->options[$oid]->{$key} = $value;
}
}
}
}