I have an entityreference on my feed importer node
I want this entityreference value to be the same for all the feeds that I use the importer for.

thanks!

Comments

SocialNicheGuru created an issue. See original summary.

megachriz’s picture

Status: Active » Fixed

I don't think there is a ready made solution for it.

You could achieve this by implementing hook_feeds_parser_sources_alter() in a custom module and then, in the accompanied callback, return the entityreference value. Something like this (untested):

/**
 * Implements hook_feeds_parser_sources_alter().
 */
function mymodule_feeds_parser_sources_alter(&$sources, $content_type) {
  $sources['my_entity_reference_field'] = array(
    'name' => t('My Entity reference field'),
    'callback' => 'mymodule_get_entity_reference',
  );
}

/**
 * Callback for getting the entity reference value from the FeedsSource.
 */
function mymodule_get_entity_reference(FeedsSource $source, FeedsParserResult $result, $key) {
  try {
    return entity_metadata_wrapper('node', $source->feed_nid)->field_reference->raw();
  }
  catch (EntityMetadataWrapperException $e) {
    // Ignore any metadata exceptions.
  }
}
socialnicheguru’s picture

mxr576’s picture

What I was looking for is implemented in new Feeds Entity.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.