Is there a way to import a currency type when doing a Feeds import? I have tried using the Feeds Tamper add on and am currently looking at this solution. It seems that I am trying to reinvent the wheel :) I have created a cck field that was called "price" as a text field and it worked beautifully. I created this as a currency field and the new "price" currency field doesn't show up as an option to map to on the mapper UI. I exported the Feed Import and added the field manually and then imported it back in. When I run the import it doesn't bring over the value that is mapped.
1 Answer
I believe I found a fairly hacky answer for now. In feeds/mappers/content.inc I modified the function content_feeds_set_target after I added the money type to the array of included field types in line 18
function content_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]['value'] = $v;
}
$i++;
}
}
else {
$field[0]['value'] = $value;
//added these two lines to take care of the Money field
$field[0]['amount'] = $value;
$field[0]['currency'] = 'USD';
}
$node->$target = $field;
}
I know that this isn't the way to develop in Drupal and most likely I need to set up another content type or something along that line but this helped me (who am a complete noob to Drupal) to get started importing the price field.
if (in_array($field['type'], array('text', 'number_integer', 'number_decimal', 'number_float')))
I think this is where the issue lies.