I am trying to import a CSV of user profiles. I have set up a feed using the entity processor branch to allow setting the processor to: "Entity processor Profile". On the settings page for the processor I have the following:
"Default values
Most of the values below can be overriden by mapping a value." (Also there is a minor spelling mistake there = "overridden")

Type *
{Contact Profile}
Label
{Blank}
Date created
{Blank}
User * 
{1}

In my mapping I have a csv column called 'uid' mapped to the User target. I believe that should override the author of the profile but it does not. All the profiles are imported linked to user 1.
I tried to take a look through the code but couldn't find where the defaults are set in the time I had.

Comments

lolcode’s picture

Title: Enity Processor branch: Default author of entity not overidden by mapping to uid » Entity Processor branch: Default author of entity not overidden by mapping to uid

I have noticed another issue. I am not sure if it is related. The choice of "Entity processor Profile" is not properly staying persistent. When I edit the feed and return to the Processor choice page it has reset the radio button to "Entity processor User". I confirmed this by re-saving this page, leaving the processor choice page and returning. However, it is not losing my settings for the "Entity processor Profile". If I click on processor settings it still has the Contact Profile selected in the dropdown. Also the import process is creating Profiles not users, it's just that all of them are owned by user 1.

Also fixing typo in title.

Sharique’s picture

I'm having same problem.
It would be better if matching is done using either username or email.

retiredpro’s picture

Issue summary: View changes

Same problem here using the latest dev version of feeds. Anybody found a solution yet?

ctrlADel’s picture

I was able to work around this by copying the setTargetElement function from FeedsNodeProcessor.inc and putting it into FeedsEntityProcessor.inc then modifying it as I needed. My function ended up looking like this:

  public function setTargetElement(FeedsSource $source, $target_node, $target_element, $value) {
    switch ($target_element) {
      case 'author':
          $target_node->uid = $value;
        break;
      default:
        parent::setTargetElement($source, $target_node, $target_element, $value);
        break;
    }
  }

I have a column of uid's so I simply set the uid of the node to the mapped value.

gerson.analista’s picture

I'm having the same problem to import the type Profile2 entities. The code #4 worked to me, I only had to change the line "case 'author':" to "case 'user':"

public function setTargetElement(FeedsSource $source, $target_node, $target_element, $value) {
    switch ($target_element) {
      case 'user':
          $target_node->uid = $value;
        break;
      default:
        parent::setTargetElement($source, $target_node, $target_element, $value);
        break;
    }
  }
MegaChriz’s picture

Project: Feeds » Feeds entity processor
Version: 7.x-2.x-dev » 7.x-1.x-dev

Moving to the Feeds entity processor project, the new home for the generic entity processor.

Eidolon Night’s picture

Here's a patch for #5 which is also working for me.

GuyPaddock’s picture

Status: Needs review » Needs work

This is now broken with the last commits to 7.x-1.x. We end up with setTargetElement() being declared twice.

ctrlADel’s picture

With this in the dev branch

  /**
   * {@inheritdoc}
   */
  public function setTargetElement(FeedsSource $source, $target_item, $target_element, $value, array $mapping = array()) {
    $properties = $this->entityProperties();
    if (isset($properties[$target_element])) {
      $plugin = feeds_entity_processor_plugin($target_element, $properties[$target_element], $this->entityWrapper($target_item), $this);
      $plugin->setValue($value, $mapping);
    }
    else {
      parent::setTargetElement($source, $target_item, $target_element, $value);
    }
  }

This issue can probably be considered fixed and closed.

GuyPaddock’s picture

@ctrlADel: Can you elaborate on how the two are related?

MegaChriz’s picture

In #2659900: Support for property type "entity" mapping to entity properties was improved. This module now has support for the following data types:

Other data types are handled the same as if it were text, so not all data types are supported yet.

If the property 'author' or 'user' (as used in the code examples) are declared as type 'user' by the module that provided the property (using an implementation of hook_entity_property_info() or hook_entity_property_info_alter()), then importing values for that property should work (at least in theory).

It is a good idea to verify first if importing these values for the reported entity types indeed works now before closing this issue. Behaviour per entity type could vary, because each entity type can have their own specific logic for operations on the entity.