chg: [command:importer] Make sure to use the latest known version of the template

pull/151/head
Sami Mokaddem 2023-03-31 13:55:48 +02:00 committed by Sami Mokaddem
parent 5cb65f8fc1
commit abd5dab605
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
1 changed files with 2 additions and 0 deletions

View File

@ -158,6 +158,7 @@ class ImporterCommand extends Command
if (!$this->noMetaTemplate) { if (!$this->noMetaTemplate) {
$metaTemplate = $this->MetaTemplates->find() $metaTemplate = $this->MetaTemplates->find()
->where(['uuid' => $config['metaTemplateUUID']]) ->where(['uuid' => $config['metaTemplateUUID']])
->order(['version' => 'DESC'])
->first(); ->first();
if (!is_null($metaTemplate)) { if (!is_null($metaTemplate)) {
$metaTemplateFieldsMapping = $this->MetaTemplates->MetaTemplateFields->find('list', [ $metaTemplateFieldsMapping = $this->MetaTemplates->MetaTemplateFields->find('list', [
@ -192,6 +193,7 @@ class ImporterCommand extends Command
$metaEntity->field = $fieldName; $metaEntity->field = $fieldName;
$metaEntity->scope = $table->getBehavior('MetaFields')->getScope(); $metaEntity->scope = $table->getBehavior('MetaFields')->getScope();
$metaEntity->meta_template_id = $metaTemplate->id; $metaEntity->meta_template_id = $metaTemplate->id;
$metaEntity->meta_template_directory_id = $metaTemplate->meta_template_directory_id;
if (isset($metaTemplateFieldsMapping[$fieldName])) { // a meta field template must exists if (isset($metaTemplateFieldsMapping[$fieldName])) { // a meta field template must exists
$metaEntity->meta_template_field_id = $metaTemplateFieldsMapping[$fieldName]; $metaEntity->meta_template_field_id = $metaTemplateFieldsMapping[$fieldName];
} else { } else {