The Problem
The option to "Allow source configuration override" on the Feeds XPath Parser seems to break when using Feeds Self Node Processor and Feeds Spider

Settings
Step 1: Under "Parser > Settings" I set up the XPath XML parser context and queries and select "Allow source configuration override".

Step 2: I create a number of Nodes automatically using Feeds Spider. The Xpath context and queries as per Step 1 are correctly passed to the Node, and then correctly Imported on Cron (or manually selecting Node > Import).

Step 3: I then change the general context and queries in the Xpath Parser (to get ready for the next Feeds Spider import - on the same type of Nodes).

Step 4A: On next Cron run the Xpath context and queries for the Nodes already created (Step 2) are over-written with the "new" general settings created under Step 3.
Step 4B: Also, if I manually go to Node>Edit for the Nodes created under Step 1&2, then the context and queries created under Step 3 (not Step 1) are shown

How to fix?
Insert a couple of lines of code to see if XPath Parser fields have values on a Node, and if they do, then skip calling the current configuration (regardless if the Node has been created manually, or automatically using a Feeds Spider).

Any idea what this code is, or where to put it? I'm willing to pay to get this resolved asap (need it for a live project) - thanks!

I'm not sure if the problem is arising from Feeds Xpath Parser, Feeds Spider, or Feeds Self Node Processor module (or somewhere else?!)

Comments

swfindlay’s picture

On further investigation it seems that this is a Feeds Xpath Parser module issue:

- For the "Allow source configuration override" you need to manually go into each Node, change at least one of the XPath queries or context, and then these mappings will be retained, regardless of any subsequent changes made to the general mappings.

It would be great if the "Allow source configuration override" would work on Nodes that have been created automatically (e.g. via Feeds Spider) as well.

Is there any easy way of doing this?

swfindlay’s picture

Title: Feeds XPath Parser "Allow source configuration override" doesn't appear to work with Feeds Self Node Proessor and Feeds Spider » Feeds XPath Parser and Feeds Self Node Processor: automatically save different XPath Parser settings across lots of Nodes
Status: Active » Needs review

So I've made (with the help of others & the Drupal community) a (really bad) hack to solve this:

1. The XPath Parser file automatically deletes XPath settings on a Node, if the Node settings are the same as the General settings. I guess this is to save overhead, but is a pain if you want to store XPath Parswer settings on every Node (which I need to do).

So first off, lines of code 331-353 of FeedsXPathParserBase.inc need to be amended as follows:

  /**
   * Override parent::sourceFormValidate().
   *
   * If the values of this source are the same as the base config we DO NOT set them to
   * blank so that the values will NOT be inherited from the importer defaults.
   *
   * @param &$values
   *   The values from the form to validate, passed by reference.
   */
  public function sourceFormValidate(&$values) {
    $config = $this->getConfig();
    $values = $values['xpath'];
    ksort($values);

    $this->configFormValidate($values);
  } 

2. Then to pass the General Settings to each Node, requires a manual Node - Edit then Save. Which is ok for a few Nodes, but impractical for lots of Nodes.

So a hacked way to do this to, use VBO and Execute a PHP snippet (thanks Nikit and AVR):

$test = node_load($entity->nid);
module_load_include('inc', 'node', 'node.pages');
$test_state['values']['op'] = t('Save');
drupal_form_submit('YOURNODETYPE_node_form', $test_state, $test);

This then enables you to mass update lots of Nodes with a General setting of Xpath parser. Then change the General settings for the Xpath Parser and mass update a whole other set of Nodes with the new settings. Without destroying the settings on the 1st bunch of Nodes.

Hope that helps - please comment if there is a simpler / faster / better / more robust way of doing this. I'm sure there is!!

vimaljoseph’s picture

I faced a similar issue https://drupal.org/node/2180631 Not sure the code posted there is the right way to fix the issue. Can anyone guide me on this?

twistor’s picture

Version: 7.x-1.0-beta3 » 7.x-1.x-dev
Category: Bug report » Feature request
Priority: Major » Normal
Status: Needs review » Needs work

This is more of a problem with your expectations than a bug.

Generally speaking, you shouldn't be importing node and then changing configuration. You should be creating multiple importers to accomplish this.

twistor’s picture

Status: Needs work » Closed (works as designed)

I agree that this was a bad design decision, but it's too late now to fix it.