I have defined the unique key of my migration with a specific field (field is defined in fields section). But, in several cases, I see that the source data of this field is empty. If the unique key is populated with 1 null value, the map of my migration has null values. It's a problem.

I want to test the source value and if no data, create a custom value. For this, I have created a custom source plugin, this plugin extends the url plugin, and alter the value of 1 field ('myfield'). I pass this field in the ids section of my config file. Here is the code:

class MyCustomPlugin extends Url  {
  * {@inheritdoc}
 public function prepareRow(Row $row) {
   // Retrieve the source data
   $default_data = $row->getSourceProperty('default_data');
   $second_data = $row->getSourceProperty('second_data');
   if (empty($default_data)) {
     $row->setSourceProperty('myfield', $second_data);
   return parent::prepareRow($row);

But, the loop on each item seems to be broken. Only the first item is upgraded. I think that the ids() function must receive a value with another method.

How can I resolve my problem and send the custom value in my ids() function for all items ?

Thanks for your help.

Your Answer

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

Browse other questions tagged or ask your own question.