Loading modules/commerce/commerce_migrate_commerce.module +7 −12 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ */ use Drupal\Core\Routing\RouteMatchInterface; use Drupal\commerce_migrate_commerce\Attributes; use Drupal\commerce_migrate_commerce\Plugin\migrate\source\commerce1\Profile; use Drupal\field\Plugin\migrate\source\d7\Field; use Drupal\field\Plugin\migrate\source\d7\FieldInstance; Loading @@ -13,7 +14,6 @@ use Drupal\field\Plugin\migrate\source\d7\FieldInstancePerFormDisplay; use Drupal\field\Plugin\migrate\source\d7\FieldInstancePerViewMode; use Drupal\field\Plugin\migrate\source\d7\ViewMode; use Drupal\migrate\Exception\RequirementsException; use Drupal\migrate\Plugin\MigrationDeriverTrait; use Drupal\migrate_drupal\Plugin\migrate\FieldMigration; use Drupal\node\Plugin\migrate\source\d7\Node; use Drupal\taxonomy\Plugin\migrate\source\d7\Term; Loading Loading @@ -307,19 +307,14 @@ function _commerce_migrate_commerce_get_field_name() { * An array of taxonomy vocabularies that are product attributes.. */ function _commerce_migrate_commerce_get_attributes() { $source_plugin = MigrationDeriverTrait::getSourcePlugin('d7_field_instance'); $rows = Attributes::getAttributeRows(); $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')) { // Get all bundles for this field. foreach ($rows as $row) { $field_definition = $row->getSourceProperty('field_definition'); $data = unserialize($field_definition['data']); foreach ($data['settings']['allowed_values'] as $allowed_value) { $attributes[] = $allowed_value['vocabulary']; } } } return array_unique($attributes); } modules/commerce/src/Attributes.php 0 → 100644 +30 −0 Original line number Diff line number Diff line <?php namespace Drupal\commerce_migrate_commerce; use Drupal\migrate\Plugin\MigrationDeriverTrait; /** * Get the attribute rows from the d7_field_instance source plugin. */ class Attributes { use MigrationDeriverTrait; /** * Get d7_field_instance rows that are for product attributes. * * @return \Drupal\migrate\Row[] * The source plugin rows that are for taxonomy term reference fields, that * are using options select and for commerce products. */ public static function getAttributeRows() { $source_plugin = self::getSourcePlugin('d7_field_instance'); return array_filter(iterator_to_array($source_plugin), function ($row) { return (($row->getSourceProperty('entity_type') == 'commerce_product') && ($row->getSourceProperty('type') == 'taxonomy_term_reference') && ($row->getSourceProperty('widget')['type'] == 'options_select')); }); } } modules/commerce/src/EventSubscriber/MigratePrepareRow.php +3 −1 Original line number Diff line number Diff line Loading @@ -15,6 +15,8 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface; */ class MigratePrepareRow implements EventSubscriberInterface { use MigrationDeriverTrait; /** * Product node types. * Loading Loading @@ -94,7 +96,7 @@ class MigratePrepareRow implements EventSubscriberInterface { * An array of taxonomy vocabularies that are product attributes.. */ protected function getAttributes() { $source_plugin = MigrationDeriverTrait::getSourcePlugin('d7_field_instance'); $source_plugin = $this->getSourcePlugin('d7_field_instance'); $attributes = []; foreach ($source_plugin as $row) { if (($row->getSourceProperty('entity_type') == 'commerce_product') && Loading modules/commerce/src/Plugin/migrate/OrderItemDeriver.php +1 −1 Original line number Diff line number Diff line Loading @@ -92,7 +92,7 @@ class OrderItemDeriver extends DeriverBase implements ContainerDeriverInterface $values['label'] = $this->t('@label (@type)', [ '@label' => $values['label'], '@type' => $row->getSourceProperty('name'), '@type' => $row->getSourceProperty('type'), ]); $values['source']['line_item_type'] = $line_item_type; $values['destination']['default_bundle'] = $line_item_type; Loading modules/commerce/src/Plugin/migrate/ProductDeriver.php +1 −1 Original line number Diff line number Diff line Loading @@ -90,7 +90,7 @@ class ProductDeriver extends DeriverBase implements ContainerDeriverInterface { $values['label'] = $this->t('@label (@type)', [ '@label' => $values['label'], '@type' => $row->getSourceProperty('name'), '@type' => $row->getSourceProperty('type'), ]); $values['source']['product_type'] = $product_type; $values['destination']['default_bundle'] = $product_type; Loading Loading
modules/commerce/commerce_migrate_commerce.module +7 −12 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ */ use Drupal\Core\Routing\RouteMatchInterface; use Drupal\commerce_migrate_commerce\Attributes; use Drupal\commerce_migrate_commerce\Plugin\migrate\source\commerce1\Profile; use Drupal\field\Plugin\migrate\source\d7\Field; use Drupal\field\Plugin\migrate\source\d7\FieldInstance; Loading @@ -13,7 +14,6 @@ use Drupal\field\Plugin\migrate\source\d7\FieldInstancePerFormDisplay; use Drupal\field\Plugin\migrate\source\d7\FieldInstancePerViewMode; use Drupal\field\Plugin\migrate\source\d7\ViewMode; use Drupal\migrate\Exception\RequirementsException; use Drupal\migrate\Plugin\MigrationDeriverTrait; use Drupal\migrate_drupal\Plugin\migrate\FieldMigration; use Drupal\node\Plugin\migrate\source\d7\Node; use Drupal\taxonomy\Plugin\migrate\source\d7\Term; Loading Loading @@ -307,19 +307,14 @@ function _commerce_migrate_commerce_get_field_name() { * An array of taxonomy vocabularies that are product attributes.. */ function _commerce_migrate_commerce_get_attributes() { $source_plugin = MigrationDeriverTrait::getSourcePlugin('d7_field_instance'); $rows = Attributes::getAttributeRows(); $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')) { // Get all bundles for this field. foreach ($rows as $row) { $field_definition = $row->getSourceProperty('field_definition'); $data = unserialize($field_definition['data']); foreach ($data['settings']['allowed_values'] as $allowed_value) { $attributes[] = $allowed_value['vocabulary']; } } } return array_unique($attributes); }
modules/commerce/src/Attributes.php 0 → 100644 +30 −0 Original line number Diff line number Diff line <?php namespace Drupal\commerce_migrate_commerce; use Drupal\migrate\Plugin\MigrationDeriverTrait; /** * Get the attribute rows from the d7_field_instance source plugin. */ class Attributes { use MigrationDeriverTrait; /** * Get d7_field_instance rows that are for product attributes. * * @return \Drupal\migrate\Row[] * The source plugin rows that are for taxonomy term reference fields, that * are using options select and for commerce products. */ public static function getAttributeRows() { $source_plugin = self::getSourcePlugin('d7_field_instance'); return array_filter(iterator_to_array($source_plugin), function ($row) { return (($row->getSourceProperty('entity_type') == 'commerce_product') && ($row->getSourceProperty('type') == 'taxonomy_term_reference') && ($row->getSourceProperty('widget')['type'] == 'options_select')); }); } }
modules/commerce/src/EventSubscriber/MigratePrepareRow.php +3 −1 Original line number Diff line number Diff line Loading @@ -15,6 +15,8 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface; */ class MigratePrepareRow implements EventSubscriberInterface { use MigrationDeriverTrait; /** * Product node types. * Loading Loading @@ -94,7 +96,7 @@ class MigratePrepareRow implements EventSubscriberInterface { * An array of taxonomy vocabularies that are product attributes.. */ protected function getAttributes() { $source_plugin = MigrationDeriverTrait::getSourcePlugin('d7_field_instance'); $source_plugin = $this->getSourcePlugin('d7_field_instance'); $attributes = []; foreach ($source_plugin as $row) { if (($row->getSourceProperty('entity_type') == 'commerce_product') && Loading
modules/commerce/src/Plugin/migrate/OrderItemDeriver.php +1 −1 Original line number Diff line number Diff line Loading @@ -92,7 +92,7 @@ class OrderItemDeriver extends DeriverBase implements ContainerDeriverInterface $values['label'] = $this->t('@label (@type)', [ '@label' => $values['label'], '@type' => $row->getSourceProperty('name'), '@type' => $row->getSourceProperty('type'), ]); $values['source']['line_item_type'] = $line_item_type; $values['destination']['default_bundle'] = $line_item_type; Loading
modules/commerce/src/Plugin/migrate/ProductDeriver.php +1 −1 Original line number Diff line number Diff line Loading @@ -90,7 +90,7 @@ class ProductDeriver extends DeriverBase implements ContainerDeriverInterface { $values['label'] = $this->t('@label (@type)', [ '@label' => $values['label'], '@type' => $row->getSourceProperty('name'), '@type' => $row->getSourceProperty('type'), ]); $values['source']['product_type'] = $product_type; $values['destination']['default_bundle'] = $product_type; Loading