protected function MigratePrepareRow::getProductTypes 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::getProductTypes()
- 3.1.x modules/commerce/src/EventSubscriber/MigratePrepareRow.php \Drupal\commerce_migrate_commerce\EventSubscriber\MigratePrepareRow::getProductTypes()
Helper to get the product types from the source database.
Parameters
\Drupal\migrate_plus\Event\MigratePrepareRowEvent $event: The event.
Return value
array An array of product type names.
1 call to MigratePrepareRow::getProductTypes()
- MigratePrepareRow::prepareRow in modules/
commerce/ src/ EventSubscriber/ MigratePrepareRow.php - Responds to prepare row event.
File
- modules/
commerce/ src/ EventSubscriber/ MigratePrepareRow.php, line 66
Class
- MigratePrepareRow
- Handles migrate_plus prepare row event.
Namespace
Drupal\commerce_migrate_commerce\EventSubscriberCode
protected function getProductTypes(MigratePrepareRowEvent $event) {
if (!empty($this->productTypes)) {
return $this->productTypes;
}
/** @var \Drupal\migrate\Plugin\Migration $migration */
$migration = $event
->getMigration();
/** @var \Drupal\migrate\Plugin\migrate\source\SqlBase $source_plugin */
$source_plugin = $migration
->getSourcePlugin();
if (method_exists($source_plugin, 'getDatabase')) {
$connection = $source_plugin
->getDatabase();
if ($connection
->schema()
->tableExists('node_type')) {
$query = $connection
->select('commerce_product_type', 'pt')
->fields('pt', [
'type',
]);
$product_node_types = $query
->execute()
->fetchCol();
return $product_node_types;
}
}
return [];
}