Commit e87e7502 authored by Aleksey.Alekseev's avatar Aleksey.Alekseev
Browse files

More levels of Taxonomy

parent 8b3a86f9
......@@ -152,6 +152,21 @@ class DrushContentImport extends DrushCommands {
*/
private function importTaxonomy($data) {
$storage = \Drupal::entityTypeManager()->getStorage('taxonomy_term');
$vocabulary_storage = \Drupal::entityTypeManager()->getStorage('taxonomy_vocabulary');
if (empty($vocabulary_storage->load($data['vid']))) {
if (!empty($data['vname'])) {
$vocabulary_name = $data['vname'];
}
else {
$vocabulary_name = $data['vid'];
}
$t = [
'vid' => $data['vid'],
'name' => $vocabulary_name,
];
$vocabulary = $vocabulary_storage->create($t);
$vocabulary->save();
}
$t = [
'vid' => $data['vid'],
'name' => $data['name'],
......@@ -159,6 +174,22 @@ class DrushContentImport extends DrushCommands {
];
$taxonomyTerm = $storage->create($t);
$taxonomyTerm->save();
if (!empty($data['children_terms'])) {
$child_terms = [];
foreach ($data['children_terms'] as $child_term) {
$t = [
'vid' => $data['vid'],
'name' => $child_term['name'],
'field_catalog_image' => $this->importImages($child_term['field_catalog_image']),
'weight' => $child_term['weight'],
'parent' => [
['target_id' => $this->getTidByName($data['name'])],
],
];
$term = $storage->create($t);
$term->save();
}
}
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment