0

I have data in xml which I want to import into drupal. Which works fine. But one field in the xml is filled with a comma separated list of terms. There is a target field in drupal which is a multi-valued field. I do not need those as a taxonomy, just as multi-value for solr search. I just want to expand the one,fourty,flower,... values to fill the multiple-value field.

It absolutely will not work. Any help?

Here is the latest iteration (I tried a lot in the last two days) which fails spectacularly with an error like so:

Error: Unsupported operand types in /var/www/dev.diercke.com/web/core/modules/migrate/src/Plugin/migrate/process/SubProcess.php on line 206 #0 /var/www/dev.diercke.com/web/core/modules/migrate/src/MigrateExecutable.php(399): Drupal\migrate\Plugin\migrate\process\SubProcess->transform(Array, Object(Drupal\migrate_tools\MigrateExecutable), Object(Drupal\migrate\Row), 'field_stichwort...')
#1 /var/www/dev.diercke.com/web/core/modules/migrate/src/MigrateExecutable.php(205): Drupal\migrate\MigrateExecutable->processRow(Object(Drupal\migrate\Row))
#2 /var/www/dev.diercke.com/vendor/drush/drush/includes/drush.inc(206): Drupal\migrate\MigrateExecutable->import()
#3 /var/www/dev.diercke.com/vendor/drush/drush/includes/drush.inc(197): drush_call_user_func_array(Array, Array)
#4 /var/www/dev.diercke.com/web/modules/contrib/migrate_tools/src/Commands/MigrateToolsCommands.php(958): drush_op(Array)
#5 [internal function]: Drupal\migrate_tools\Commands\MigrateToolsCommands->executeMigration(Object(Drupal\migrate\Plugin\Migration), 'karte', Array)
#6 /var/www/dev.diercke.com/web/modules/contrib/migrate_tools/src/Commands/MigrateToolsCommands.php(418): array_walk(Array, Array, Array)
#7 [internal function]: Drupal\migrate_tools\Commands\MigrateToolsCommands->import('karte', Array)
#8 /var/www/dev.diercke.com/vendor/consolidation/annotated-command/src/CommandProcessor.php(257): call_user_func_array(Array, Array)
#9 /var/www/dev.diercke.com/vendor/consolidation/annotated-command/src/CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback(Array, Object(Consolidation\AnnotatedCommand\CommandData))
#10 /var/www/dev.diercke.com/vendor/consolidation/annotated-command/src/CommandProcessor.php(176): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter(Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
#11 /var/www/dev.diercke.com/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(311): Consolidation\AnnotatedCommand\CommandProcessor->process(Object(Symfony\Component\Console\Output\ConsoleOutput), Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
#12 /var/www/dev.diercke.com/vendor/symfony/console/Command/Command.php(255): Consolidation\AnnotatedCommand\AnnotatedCommand->execute(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 /var/www/dev.diercke.com/vendor/symfony/console/Application.php(1027): Symfony\Component\Console\Command\Command->run(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 /var/www/dev.diercke.com/vendor/symfony/console/Application.php(273): Symfony\Component\Console\Application->doRunCommand(Object(Consolidation\AnnotatedCommand\AnnotatedCommand), Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 /var/www/dev.diercke.com/vendor/symfony/console/Application.php(149): Symfony\Component\Console\Application->doRun(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#16 /var/www/dev.diercke.com/vendor/drush/drush/src/Runtime/Runtime.php(118): Symfony\Component\Console\Application->run(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#17 /var/www/dev.diercke.com/vendor/drush/drush/src/Runtime/Runtime.php(48): Drush\Runtime\Runtime->doRun(Array, Object(Symfony\Component\Console\Output\ConsoleOutput))
#18 /var/www/dev.diercke.com/vendor/drush/drush/drush.php(72): Drush\Runtime\Runtime->run(Array)
#19 /var/www/dev.diercke.com/vendor/drush/drush/drush(4): require('/var/www/dev.di...')
#20 {main}
Error: Unsupported operand types in Drupal\migrate\Plugin\migrate\process\SubProcess->transform() (line 206 of /var/www/dev.diercke.com/web/core/modules/migrate/src/Plugin/migrate/process/SubProcess.php).
 [warning] Drush command terminated abnormally.
...
process:
...
  field_stichworte: tags
  field_stichworte_einzeln:
    - plugin: explode
      source: tags
      limit: 10000
      delimiter: ,
    - plugin: deepen
    - plugin: sub_process
      process:
        field_stichworte_einzeln:
          - plugin: extract
            index:
              - 0
...
2

I found a solution:

fields:
    ...
    -
    name: keywords_with_comma
    label: 'keywords'
    selector: keywords
    ...
process:
    ...
    field_keywords_multi:
        - plugin: explode
          delimiter: ','
          source: keywords_with_comma
        - plugin: single_value
        - plugin: multiple_values
    ...
1
  • 1
    Perfect, thx a lot!
    – makkus
    Nov 2 at 10:46

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.