0

Drupal version: 8.7.1. Used modules:

  • Migrate
  • Migrate Plus
  • Migrate Tools
  • Migrate Spreadsheet

I'm trying to generate a taxonomy term if this does not already exist. the migration file:

...
source:
  plugin: spreadsheet
  columns:
   ...
   - 'Functie'
   ...
process:
  ...
  field_function:
    plugin: entity_generate
    source: 'Functie'
    value_key: name
    ignore_case: true
    bundle: function
    entity_type: taxonomy_term
  ...

The taxonomy bundle name is function and the column in the spreadsheet containing the values is 'Functie'. However, I'm getting the following error:

[error] Error: Call to a member function getConfig() on null in Drupal\migrate_plus\Plugin\migrate\process\EntityLookup->determineLookupProperties() (line 217 of /var/www/html/web/modules/contrib/migrate_plus/src/Plugin/migrate/process/EntityLookup.php)

/var/www/html/web/modules/contrib/migrate_plus/src/Plugin/migrate/process/EntityLookup.php(182): Drupal\migrate_plus\Plugin\migrate\process\EntityLookup->determineLookupProperties('field_function')

/var/www/html/web/modules/contrib/migrate_plus/src/Plugin/migrate/process/EntityGenerate.php(116): Drupal\migrate_plus\Plugin\migrate\process\EntityLookup->transform('Medewerker', Object(Drupal\migrate_tools\MigrateExecutable), Object(Drupal\migrate\Row), 'field_function')

/var/www/html/web/core/modules/migrate/src/MigrateExecutable.php(394): Drupal\migrate_plus\Plugin\migrate\process\EntityGenerate->transform('Medewerker', Object(Drupal\migrate_tools\MigrateExecutable), Object(Drupal\migrate\Row), 'field_function')

/var/www/html/web/core/modules/migrate/src/MigrateExecutable.php(203): Drupal\migrate\MigrateExecutable->processRow(Object(Drupal\migrate\Row))

/var/www/html/vendor/drush/drush/includes/drush.inc(223): Drupal\migrate\MigrateExecutable->import()

/var/www/html/vendor/drush/drush/includes/drush.inc(214): drush_call_user_func_array(Array, Array)

/var/www/html/web/modules/contrib/migrate_tools/src/Commands/MigrateToolsCommands.php(766): drush_op(Array)

[internal function]: Drupal\migrate_tools\Commands\MigrateToolsCommands->executeMigration(Object(Drupal\migrate\Plugin\Migration), 'profiles', Array)

/var/www/html/web/modules/contrib/migrate_tools/src/Commands/MigrateToolsCommands.php(321): array_walk(Array, Array, Array)

[internal function]: Drupal\migrate_tools\Commands\MigrateToolsCommands->import('profiles', Array)

/var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(257): call_user_func_array(Array, Array)

/var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback(Array, Object(Consolidation\AnnotatedCommand\CommandData))

/var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(178): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter(Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))

/var/www/html/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(302): Consolidation\AnnotatedCommand\CommandProcessor->process(Object(Symfony\Component\Console\Output\ConsoleOutput), Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))

/var/www/html/vendor/symfony/console/Command/Command.php(255): Consolidation\AnnotatedCommand\AnnotatedCommand->execute(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

/var/www/html/vendor/symfony/console/Application.php(978): Symfony\Component\Console\Command\Command->run(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

/var/www/html/vendor/symfony/console/Application.php(255): Symfony\Component\Console\Application->doRunCommand(Object(Consolidation\AnnotatedCommand\AnnotatedCommand), Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

/var/www/html/vendor/symfony/console/Application.php(148): Symfony\Component\Console\Application->doRun(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

/var/www/html/vendor/drush/drush/src/Runtime/Runtime.php(118): Symfony\Component\Console\Application->run(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

/var/www/html/vendor/drush/drush/src/Runtime/Runtime.php(49): Drush\Runtime\Runtime->doRun(Array, Object(Symfony\Component\Console\Output\ConsoleOutput))

/var/www/html/vendor/drush/drush/drush.php(72): Drush\Runtime\Runtime->run(Array)

/var/www/html/vendor/drush/drush/includes/preflight.inc(18): require('/var/www/html/v...')

phar:///usr/local/bin/drush/bin/drush.php(141): drush_main() /usr/local/bin/drush(10): require('phar:///usr/loc...')

If anyone could point out what's going wrong, by all means, enlighten me because I have no clue what's going on, the configuration seems right to me.

  • This doesn't lool like a valid YML, leading whitespaces are very importtant in YML. You need to intend - 'Functie' to the proper level – Hudri May 17 at 8:58
  • Yeah my bad, edited the yaml in this post. this is how it looks like in my file. – Geordi Feijens May 17 at 9:01
  • Not sure if it helps, but try explicitly listing the bundle_key below field_function: bundle_key: vid – Hudri May 17 at 10:04
  • Oh yeah, that fixed it for me! Thanks a bunch @Hudri! – Geordi Feijens May 17 at 11:45
0

You need to explode your source - I used a comma in this case. You then need to generate against the specific vid you want to import into:

Try something like this:

fields:
-
  name: name_i_gave_this_field
  label: 'Taxonomy Term I want to Import'
  selector: termname
process: 
  field_my_entity_reference_to_taxonomy:
 -
  plugin: explode
  source: name_i_gave_this_field
  delimiter: ','
-
  plugin: entity_generate
  lookupBundleKey: vid
  lookupBundle: my_vocabulary_name

Make sure that your Taxonomy Term reference field allows you to create content.

  • Isn't explode only used when you have multiple values in one cell ? Also, it doesn't seem like i'm able to use the fields since I'm using the spreadsheet plugin. I've only started with migrations since a few days ago so I'm not sure tho'. – Geordi Feijens May 17 at 9:08
  • Sorry, that was my presumption that you might have more than one value. Simply set the first source to: plugin: default_value source: name_i_gave_this_field – macjules May 17 at 9:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.