I would like to suggest adding "pseudo-fields" that one can map Xpaths too. These wouldn't need to actually be present on the target bundle, but would be used to attach metadata to the entity, that could be used during import.

My use case:

I gather data with the feeds module and xpathparser.

Sample data 1:


Sample data 2:


In the incoming XML data, there are two fields, used to signify an old entry should be deleted. In my feeds Parser->parse(), I have

$this->config['sources']['refid'] = 'XML/ref-id';
$this->config['sources']['action'] = 'XML/action';

which makes the parser get these two data values even if I don't map them to a field. But I can find no way of making this information available to the Processor. I would like to find some way of sticking this data on to the $node, so that in entitySave() I can ignore saving id 1235 and instead delete 1234.

Currently I solve this by abusing drupal_static to pass data between the parse and entitySave functions.


twistor’s picture

In Feeds Tamper, there's something called the "Temporary target." That gets you half the way there. I mostly used it for rewriting fields, but it would be trivial to add a legit mapper, that maps it to a temporary field on the entity.

twistor’s picture

Title: Temporary "pseudo" fields for mapping arbitrary data to? » Map "Temporary target" to a property of an entity.
Project: Feeds XPath Parser » Feeds Tamper

Moving to Feeds Tamper. It's outside the scope of the XPath Parser.

emptyvoid’s picture

Just a note adding a target of "Temporary target" for any xpathparser results in a "missing" target.

That said, it still works.

1) Temporary target -> source xpath
2) Blank Source -> use temporary target value.

I parse the temporary target value through a tamper than save it to the property of the target node.

yang_yi_cn’s picture

It looks like the "Temporary target" thing doesn't work with Entities though, it might work with nodes. But in Entity API module the following function will throw a warning saying "Unknown data property Temporary Target 1".

  public function getPropertyInfo($name = NULL) {
    if (!isset($name)) {
      return $this->propertyInfo['properties'];
    if (!isset($this->propertyInfo['properties'][$name])) {
      throw new EntityMetadataWrapperException('Unknown data property ' . check_plain($name) . '.');
    return $this->propertyInfo['properties'][$name] + $this->info['property defaults'] + $this->propertyInfoDefaults;

for now my work around is to set the target to be the actual field / property of the entity instead of the Temporary Target. As long as the last mapping to that target does a rewrite it looks still works.

twistor’s picture

#4, what is your setup? It should work with any entity just fine. What you're referring to is the EntityMetadataWrapper, I'm not aware off hand of any processors that return those to targets.

yang_yi_cn’s picture

@twistor I'm using ECK to create my custom entities, which supports fields API and custom properties such as language, author or status for entities.

so It's a rather complicated setup with ECK + Entity API + Feeds + Feeds tamper. I also have Entity translation and feeds_et running but I think they are not the cause of this problem. I also had to use quite a few patches of these modules to make them all work together.

yang_yi_cn’s picture

Issue summary: View changes

Explaing my current workaround better.