protected function MigratePrepareRow::getAttributes in Commerce Migrate 8.2
Same name and namespace in other branches
- 3.1.x modules/commerce/src/EventSubscriber/MigratePrepareRow.php \Drupal\commerce_migrate_commerce\EventSubscriber\MigratePrepareRow::getAttributes()
- 3.0.x modules/commerce/src/EventSubscriber/MigratePrepareRow.php \Drupal\commerce_migrate_commerce\EventSubscriber\MigratePrepareRow::getAttributes()
Get the fields that are commerce product attributes.
Attributes use taxonomy term reference fields with options.
Return value
array An array of taxonomy vocabularies that are product attributes..
See also
https://drupalcommerce.org/user-guide/product-attributes-variations
File
- modules/
commerce/ src/ EventSubscriber/ MigratePrepareRow.php, line 96
Class
- MigratePrepareRow
- Handles migrate_plus prepare row event.
Namespace
Drupal\commerce_migrate_commerce\EventSubscriberCode
protected function getAttributes() {
$source_plugin = MigrationDeriverTrait::getSourcePlugin('d7_field_instance');
$attributes = [];
foreach ($source_plugin as $row) {
if ($row
->getSourceProperty('entity_type') == 'commerce_product' && $row
->getSourceProperty('type') == 'taxonomy_term_reference' && $row
->getSourceProperty('widget')['type'] == 'options_select') {
$name = str_replace('field_', '', $row
->getSourceProperty('field_name'));
$attributes[] = $name;
}
}
return array_unique($attributes);
}