When migrating products, all the field instances are migrated correctly but only the title seems to be populated, all other additional fields such as body or image are blank and don’t appear to be migrated.

Comments

rviner created an issue. See original summary.

quietone’s picture

Status: Active » Postponed (maintainer needs more info)

Thanks for the report.

There isn't enough information here to look into why this is happening. It is a good idea to provide steps to reproduce the problem. Also for a migration it helps to know how you are running the migration and where the source data is coming from (CSV, Ubertcart, Commerce 1 or something else). And it would help to know how you know the values are not migrated? For example, is this from the UI or did you look in the database?

rviner’s picture

I’m using Drush from a drupal 7 instance using Ubercart:

drush migrate-upgrade --legacy-db-url=mysql://user:password@server/db --legacy-root=http://example.com --configure-only

Then

drush migrate-import --all

I looked in the d8 database and the field instance tables are empty.

rviner’s picture

Status: Postponed (maintainer needs more info) » Active
quietone’s picture

Status: Active » Postponed (maintainer needs more info)

What errors, if any, were there. Can you post the output from running 'drush migrate-import --all'. Were there non product nodes on the site with fields and did they migrate?

rviner’s picture

- There are no errors.

- There were non product nodes on the site and all of these fields and data were migrated correctly. I was using a fairly empty Drupal 7 site to test. i.e. basic_page content with a content of fields and ubercart 7 with a couple of products.

- It says it imported the product node: Processed 1 item (1 created, 0 updated, 0 failed, 0 ignored) - done with 'upgrade_d7_node_product'

- I also noticed it's creating the product Drupal 7 text plain fields as text (formatted) fields in Drupal 8. This isn't happening for non product nodes.

rviner’s picture

Status: Postponed (maintainer needs more info) » Active
quietone’s picture

Since this was a test db and will be small, can you compress it and post it?

rviner’s picture

I'd rather avoid posting the database but you should be able to reproduce this by adding one text plain field to the drupal 7 non product type e.g. basic page and one text plain field to an ubercart product type, adding one product node and one basic page node.

You can then either run the drupal 8 migration through the Drupal UI or

drush migrate-upgrade --legacy-db-url=mysql://user:password@server/db --legacy-root=http://example.com --configure-only

Then

drush migrate-import --all

The results are the basic page fields migrate fine along with the data but the commerce product only contains the title and not the body content and the extra field data that was added. Any extra fields plain text fields are created as text formatted rather than text plain.

rviner’s picture

StatusFileSize
new112.05 KB
new195.91 KB
new118.32 KB
new102.67 KB

See screenshots for assistance.

rviner’s picture

Just wondering if the migration of text plain fields to text formatted fields is related to this issue: D7 Plain text fields incorrectly migrated to D8 as Text (formatted)

I realise this is an old issue but I am running the migration on 8.6.15

technotim2010’s picture

StatusFileSize
new31.34 KB

Hi
I have seen this as well. It was reporting issues with filter_null (i.e. there is no filter because the source was plain text and the destination is a text format that isnt plain text. Solution was to create a text format with machine name filter_null and ensure it converts line feeds into and

tags (an option in the text format. See screenshot.

Not a fix as such but it does work, This was on D6 and Ubercart 6 but I employed a similar fix in when Migrating D7 and Ubercart 7.

Tim

jastraat’s picture

I may have some more information on this. I also experienced the problem where no custom product fields migrated from Ubercart D7 (node) to Commerce D8 (product)

In the d7_field_instance migration, I see that all fields attached to my D7 product node failed. This included plain and rich text fields as well as taxonomy references, file fields, and image fields.

The error in the migration is "Missing bundle entity, entity type commerce_product_type, entity id product. "

nathaniel’s picture

I'm digging into this one a bit. Same as the original issue all products migrate with title and fields from uc7, but no field data.

Drupal core 8.9.2

So far, if I rollback the migration for d7_node:product_type

drush mr d7_node:product_type

Alter the code in core D7NodeDeriver.php:

        if ($node_type == 'product_type') {
          $this->fieldDiscovery->addBundleFieldProcesses($migration, 'commerce_product', $node_type);
        }
        else {
          $this->fieldDiscovery->addBundleFieldProcesses($migration, 'node', $node_type);
        }

Clear cache.
drush cr

drush migrate-import d7_node:product_type

The field data is migrated over as expected.

bobburns’s picture

OK regarding #14 - I did this to /core/modules/node/src/Plugin/migrate/D7NodeDeriver.php without the " + " signs of course, and no errors it ran

        $migration = \Drupal::service('plugin.manager.migration')->createStubMigration($values);
+	if ($node_type == 'product_type') {
+         $this->fieldDiscovery->addBundleFieldProcesses($migration, 'commerce_product', $node_type);
+        }
+        else {
+          $this->fieldDiscovery->addBundleFieldProcesses($migration, 'node', $node_type);
+        }
//        $this->fieldDiscovery->addBundleFieldProcesses($migration, 'node', $node_type);  //. . line which let me find the else injection point
        $this->derivatives[$node_type] = $migration->getPluginDefinition();

No joy so far . . . am I missing something ?? Does this ONLY work with Drush "migrate-upgrade" and not with the Drupal UI /upgrade path ??

nathaniel’s picture

Try changing 'product_type' to the node type that is your uc7 product and clear the cache.

nathaniel’s picture

Status: Active » Needs review
StatusFileSize
new839 bytes

Attached a patch for commerce_migrate_ubercart_migration_plugins_alter, not sure if this is the best way to do it, but it seems to be working.

          /** @var \Drupal\migrate\Plugin\MigrationInterface $stub_migration */
          $stub_migration = \Drupal::service('plugin.manager.migration')->createStubMigration($migration);
          \Drupal::service('migrate_drupal.field_discovery')->addBundleFieldProcesses($stub_migration, 'commerce_product', $node_type);
          $migration = $stub_migration->getPluginDefinition();
nathaniel’s picture

StatusFileSize
new820 bytes

Made a few minor adjustments \Drupal::service('plugin.manager.migration') is already available in a variable from the top of the function. Renamed the variable $stub_migration to $migration_stub to match the name at the top of the function. I made an interdiff, but every line was changed and the patch is pretty small so I didn't attach it.

Status: Needs review » Needs work

The last submitted patch, 18: uc7-field-data-3044987-18.patch, failed testing. View results

bobburns’s picture

The patch at 17 and 15 applied together solved the Runtime Error from https://www.drupal.org/project/commerce_migrate/issues/3044987 BUT still did not import the text data field

Checkout appears to work and I can edit and change weights and dimensions from the imported products - I will add the text and images and other minor mods by cutting and pasting and editing all 144 products now

Many thanks to Nathaniel

damienmckenna’s picture

Title: Product field data not migrated » Ubercart 7 product field data not migrated
damienmckenna’s picture

Parent issue: » #2873182: [Meta] Ubercart 7
damienmckenna’s picture

Let's handle basic fields from the content type on this issue and then in #3165421 we'll look at fields added to the Ubercart entities themselves.

nathaniel’s picture

Status: Needs work » Needs review

Changing back to needs review since tests are passing now.

quietone’s picture

Status: Needs review » Closed (duplicate)

Thanks Nathaniel, rviner, TechnoTim2010, DamienMcKenna, bobburns and jastraat for working on this.

+++ b/modules/ubercart/commerce_migrate_ubercart.module
@@ -257,6 +257,10 @@ function commerce_migrate_ubercart_migration_plugins_alter(&$migrations) {
+          $migration_stub = $migration_plugin_manager->createStubMigration($migration);
+          \Drupal::service('migrate_drupal.field_discovery')->addBundleFieldProcesses($migration_stub, 'commerce_product', $node_type);
+          $migration = $migration_stub->getPluginDefinition();

Local testing with the database changes from #3052488: Add field value migration to Ubercart 7 products suggest that this will work. However, I'd much rather call addBundleFieldProcesses once during the creation of a migration. A better solution to this problem is in #3052488: Add field value migration to Ubercart 7 products which removes the hack that caused the problem in the first place.

Moving credit to that issue and closing this as a duplicate.

If you think this is a mistake reopen the issue and add a comment with your reason.