I am trying to import nodes of type operation and ports from xml, operations have a reference entity field that refers to ports. Somehow the reference is not correct, here is my xml
operations.xml
<?xml version="1.0" encoding="UTF-8"?>
<content>
<node>
<nid>17</nid>
<title>A1</title>
<description/>
<classification>Category A</classification>
<portnid>15</portnid>
</node>
<node>
<nid>22</nid>
<title>A2</title>
<description>A2 description</description>
<classification>Category A</classification>
<portnid>21</portnid>
</node>
</content>
ports.xml
<?xml version="1.0" encoding="UTF-8"?>
<content>
<node>
<nid>15</nid>
<title>port1</title>
<port_type>1</port_type>
</node>
<node>
<nid>21</nid>
<title>port2</title>
<port_type>2</port_type>
</node>
</content>
port mappings
$this->addFieldMapping('title', 'title')
->xpath('title');
$this->addFieldMapping('field_xd_port_type', 'port_type')
->xpath('port_type');
operation mappings
$this->addFieldMapping('title', 'title')
->xpath('title');
$this->addFieldMapping('field_xd_classification', 'classification')
->xpath('classification');
$this->addFieldMapping('field_xd_operation_description', 'description')
->xpath('description');
$this->addFieldMapping('field_xd_ports', 'portnid')
->sourceMigration('importPorts');
There is no error but the ports are not correctly referenced either.
Comments
Comment #2
chantal.rosmuller commentedHere is the complete code
Comment #3
chantal.rosmuller commentedI fixed it my sqlf,
I changed the ports xml:
<?xml version="1.0" encoding="UTF-8"?>
15 port1 121 port2 2
and I changed the sourcemigration name
$this->addFieldMapping('field_xd_ports', 'portnid')
->sourceMigration('defaultports');
Adding drush_print_r to preparerow and prepare and running the migration with drush gave me some clarity about wat was going wrong.
Comment #4
chantal.rosmuller commented