protected function PrepareRow::getProductTypes in Commerce Migrate 3.1.x
Same name and namespace in other branches
- 8.2 modules/ubercart/src/EventSubscriber/PrepareRow.php \Drupal\commerce_migrate_ubercart\EventSubscriber\PrepareRow::getProductTypes()
- 3.0.x modules/ubercart/src/EventSubscriber/PrepareRow.php \Drupal\commerce_migrate_ubercart\EventSubscriber\PrepareRow::getProductTypes()
Helper to get the product types from the source database.
Parameters
\Drupal\migrate\Plugin\MigrationInterface $migration: The migration.
Return value
array The product types.
3 calls to PrepareRow::getProductTypes()
- PrepareRow::onPrepareRow in modules/
ubercart/ src/ EventSubscriber/ PrepareRow.php - Responds to prepare row event.
- PrepareRow::setCommerceProductProperty in modules/
ubercart/ src/ EventSubscriber/ PrepareRow.php - Helper to set a commerce_product property in the source row.
- PrepareRow::setEntityType in modules/
ubercart/ src/ EventSubscriber/ PrepareRow.php - Helper to set the correct entity type in the source row.
File
- modules/
ubercart/ src/ EventSubscriber/ PrepareRow.php, line 237
Class
- PrepareRow
- Handles migrate_plus prepare row event.
Namespace
Drupal\commerce_migrate_ubercart\EventSubscriberCode
protected function getProductTypes(MigrationInterface $migration) {
if (!empty($this->productTypes)) {
return $this->productTypes;
}
/** @var \Drupal\migrate\Plugin\migrate\source\SqlBase $source_plugin */
$source_plugin = $migration
->getSourcePlugin();
if (method_exists($source_plugin, 'getDatabase')) {
$this->connection = $source_plugin
->getDatabase();
if ($this->connection
->schema()
->tableExists('node_type')) {
$query = $this->connection
->select('node_type', 'nt')
->fields('nt', [
'type',
])
->condition('module', 'uc_product%', 'LIKE')
->distinct();
$this->productTypes = [
$query
->execute()
->fetchCol(),
];
}
}
return reset($this->productTypes);
}