hook_feeds_processor_targets_alter - how to set a value not in the feeds source? I need to import a csv that has only two fields (date and name) to a content type that has 3 fields:


date
name
file


The file field should be set as the name of the file being imported.

My code until now is this:

function MYMODULE_feeds_processor_targets_alter(&amp;$targets, $entity_type, $bundle_name) {
  $targets['my_feed'] = array(
    'name' =&gt; t('field_filename'),
    'description' =&gt; t('This field has the csv file name.'),
    'callback' =&gt; 'mymodule_import_filename',
  );
}

function MYMODULE_import_filename($source, $entity, $target, $value, $mapping) {
    $my_filename ='file.csv';
    $entity-&gt;{'field_'.$target}[$entity-&gt;language][]['target_id'] = $my_filename;
}


Where am I doing a mistake? Is this the way to import a value outside the file being imported?

Thanks.
I managed to get the answer to this question.

In MYMODULE_import_filename() we can get the data we want to import, in my case is just a simple text: 'file.csv'.

The simple way to do it is like this:

function MYMODULE_feeds_processor_targets_alter(&amp;$targets, $entity_type, $bundle_name) {
  $targets['my_feed'] = array(
    'name' =&gt; t('field_filename'),
    'description' =&gt; t('This field has the csv file name.'),
    'callback' =&gt; 'mymodule_import_filename',
    'real_target' =&gt; 'field_filename',
  );
}

function MYMODULE_import_filename($source, $entity, $target, $value, $mapping) {
    $my_filename ='file.csv';
    $wrapper = entity_metadata_wrapper('node', $entity);
    $wrapper-&gt;field_filename-&gt;set($my_filename);
}