1

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.

  • It's not clear what your trouble is. I recommend you spell it out rather than asking others to replicate/research it. Not sure if this will help, but are you aware of the Feeds Tamper module? It solves a lot of issues. – keva Nov 13 '12 at 15:55
  • I apologize for the slacker question. I hate it when people do that on SO. I will try to modify it to show more info. – HelloW Nov 13 '12 at 15:57
  • I modified the question. Thanks for the feedback. – HelloW Nov 13 '12 at 16:04
  • Line 18 of feeds/mappers/content.inc if (in_array($field['type'], array('text', 'number_integer', 'number_decimal', 'number_float'))) I think this is where the issue lies. – HelloW Nov 13 '12 at 16:18
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.