How to import nodes with custom fields using Feeds module and Feeds JSONPath Parser I've got a content type called 2Wd-Tractor with this structure :


Model (node title)
Engine
Transmission
Operational
Hydraulic System


Engine field is a custom field implemented using Field Api and it does have these subfields :


Make
Model
Net Power
PTO Power
Aspiration
Power Measured At
and ...


After that to make this field visible in feeds mapping hook_feeds_processor_targets_alter was implemented.

Here is the code :

foreach (field_info_instances($entity_type, $bundle_name) as $name =&gt; $instance)
{
    $info = field_info_field($name);
    unset($callback);

    if ($info['type']=='uceen2wdtractor')
    {
        //The callback for this field type goes here.
        $callback = 'TARGET_SETTER_FOR_en2wdtractor';
    }

    if (isset($callback))
    {
        $targets[$name] =array(
            'name'=&gt;check_plain($instance['label']),
            'callback' =&gt; $callback,
            'description' =&gt; t('The @label field of the node.', array('@label' =&gt; $instance['label'])),
        );
    }
}


Data is imported to Feeds using json files , An importer is provided with these settings :







finally this is my json file :



The Problem is no data is stored in Engine field . this is the dsm($node) in hook_node_presave :
There are 3 places where the problem could lie:


Data not being correctly parsed by feeds
Data not being correctly saved by feeds
Problem with the field definition itself


Number 3 is ruled out since fields save correctly via the UI.

Troubleshooting Number 1.

Add a hook_feeds_after_parse to your module and either step through with a debugger or dump the $items array to the dblog:

function mymodule_feeds_after_parse(FeedsSource $source, FeedsParserResult $result) {
  if($source-&gt;id == 'ENTER YOUR SOURCE ID HERE') {
    watchdog('My Module', '&lt;pre&gt;' . print_r($result-&gt;items, TRUE) . '&lt;/pre&gt;');
  }
}


Question: is there a value in the items array for your engine field?

If no: there is a problem in the JSON parser definitions and feeds is not extracting the data correctly.

If yes: if the information exists that you require, i.e. every sub field value exists then the problem is not with the feeds parsing.

Troubleshooting Number 2

This points to an issue with your implementation of hook_feeds_processor_targets_alter.  Most likely, the data is not in the correct format for saving.  Add some watchdog statements in this function to determine:


Is the callback being fired?
If the callback is being fired then there is an issue with your hook_feeds_set_target implementation.  It isn't providing the correct data format to allow the field to be saved.  You could add a dpm() statement to hook_node_update and then save a node via the UI. This will show the correct format.