public function MigratePrepareRow::prepareRow in Commerce Migrate 3.0.x
Same name and namespace in other branches
- 8.2 modules/commerce/src/EventSubscriber/MigratePrepareRow.php \Drupal\commerce_migrate_commerce\EventSubscriber\MigratePrepareRow::prepareRow()
- 3.1.x modules/commerce/src/EventSubscriber/MigratePrepareRow.php \Drupal\commerce_migrate_commerce\EventSubscriber\MigratePrepareRow::prepareRow()
Responds to prepare row event.
Parameters
\Drupal\migrate_plus\Event\MigratePrepareRowEvent $event: The event.
File
- modules/
commerce/ src/ EventSubscriber/ MigratePrepareRow.php, line 39
Class
- MigratePrepareRow
- Handles migrate_plus prepare row event.
Namespace
Drupal\commerce_migrate_commerce\EventSubscriberCode
public function prepareRow(MigratePrepareRowEvent $event) {
$migration = $event
->getMigration();
$row = $event
->getRow();
$source_plugin = $migration
->getSourcePlugin();
// Field instance, field formatter, field instance widget settings.
if (is_a($source_plugin, FieldInstance::class)) {
// If this is node entity then set source property 'commerce1_entity_type'
// to indicate if this is a product display node or not.
$row
->setSourceProperty('commerce1_entity_type', $row
->getSourceProperty('entity_type'));
if ($row
->getSourceProperty('entity_type') === 'node') {
if (in_array($row
->getSourceProperty('bundle'), $this
->getProductTypes($event))) {
$row
->setSourceProperty('commerce1_entity_type', 'product_display');
}
}
}
}