Link to my previous question, which has info on data structure etc.
Now I've gotten my XML read into Migrate and content type and fields set up right (I think), but now I can't get the nodes to save. The import has the correct number of nodes, but they don't ever get imported. The wine examples in the documentation didn't say anything about using prepareRow() or anything when you are using XML. Where are my nodes? Can I pull out that data with Views even if nodes don't import? My end use for this is to arrange everything with Views.
EDIT
Here is my class:
<?php
class ItemNodeMigration extends XMLMigration {
public function __construct() {
parent::__construct(MigrateGroup::getInstance('itemnode', array('default')));
$this->description = t('Grab data in XML');
// There isn't a consistent way to automatically identify appropriate "fields"
// from an XML feed, so we pass an explicit list of source fields
$fields = array(
'id' => 'ID',
'type' => t('Description of producer'),
'Owner' => t('Owner'),
'Text' => t('Text'),
'modifiedAt' => 'Date last changed',
);
$this->map = new MigrateSQLMap($this->machineName,
array(
'id' => array(
'type' => 'varchar',
'length' => 6,
'not null' => TRUE,
)
),
MigrateDestinationNode::getKeySchema()
);
// This can also be an URL instead of a file path.
$xml_folder = 'http://example.com/item/';
$list_url = 'http://example.com/CompanyID/Items.xml';
// Each ID retrieved from the list URL will be plugged into :id in the
// item URL to fetch the specific objects.
$item_url = $xml_folder . ':id/desc.xml';
$this->source = new MigrateSourceList(new MigrateListXML($list_url),
new MigrateItemXML($item_url), $fields);
$this->destination = new MigrateDestinationNode('migrate_module_itemnode');
$this->addFieldMapping('id', 'id')
->xpath('/@id');
$this->addFieldMapping('body', 'Text')
->xpath('/Text');
$this->addFieldMapping('type', 'type')
->xpath('/@type');
$this->addFieldMapping('owner', 'Owner')
->xpath('/@Owner');
$this->addFieldMapping('created', 'modifiedAt')
->xpath('/@modifiedAt');
}
}
EDIT2: I have determined that my problem lies here:
$this->map = new MigrateSQLMap($this->machineName,
array(
'id' => array(
'type' => 'varchar',
'length' => 6,
'not null' => TRUE,
)
),
MigrateDestinationNode::getKeySchema()
);
This isn't correctly mapping to my source's ID, which lies at Item/@id. How can I correct this?
MigrateDestination
value. Such as MigrateDestinationNode, or MigrateDestinationEntity, or MigrateDestinationTable. – tenken Jan 15 '13 at 21:13