Skip to content
Snippets Groups Projects
Commit a11c4504 authored by milesw's avatar milesw Committed by MegaChriz
Browse files

Issue #2147341 by milesw: fixed missing bundle property on entity of type...

Issue #2147341 by milesw: fixed missing bundle property on entity of type taxonomy_term when replacing existing terms.
parent dd038fe1
No related branches found
No related tags found
No related merge requests found
......@@ -38,6 +38,21 @@ class FeedsTermProcessor extends FeedsProcessor {
return $term;
}
/**
* Load an existing entity.
*/
protected function entityLoad(FeedsSource $source, $entity_id) {
$entity = parent::entityLoad($source, $entity_id);
// Avoid missing bundle errors when term has been loaded directly from db.
if (empty($entity->vocabulary_machine_name) && !empty($entity->vid)) {
$vocabulary = taxonomy_vocabulary_load($entity->vid);
$entity->vocabulary_machine_name = ($vocabulary) ? $vocabulary->machine_name : NULL;
}
return $entity;
}
/**
* Validates a term.
*/
......
......@@ -348,4 +348,32 @@ class FeedsCSVtoTermsTest extends FeedsWebTestCase {
}
}
/**
* Test replacing terms on subsequent imports.
*/
public function testReplaceTerms() {
$mappings = array(
0 => array(
'source' => 'name',
'target' => 'name',
'unique' => 1,
),
);
$this->addMappings('term_import', $mappings);
// Configure the processor to "Replace existing terms".
$this->setSettings('term_import', 'FeedsTermProcessor', array(
'skip_hash_check' => TRUE,
'update_existing' => 1,
));
// Import first time.
$this->importFile('term_import', $this->absolutePath() . '/tests/feeds/users.csv');
$this->assertText('Created 5 terms');
// Import again to replace terms.
$this->importFile('term_import', $this->absolutePath() . '/tests/feeds/users.csv');
$this->assertText('Updated 5 terms.');
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment