Problem/Motivation

Possibly a bad idea simply because of how big a change it would be...

But ProductVariation source is fundamentally a node migration, with extra data from the uc_products table added.

Currently, it doesn't have access to any CCK fields on the node.

If it inherited from Drupal\node\Plugin\migrate\source\d6\Node, then we'd get those automatically.

Proposed resolution

Option 1: extend it from Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase\FieldableEntity and then have the methods getFields() and getFieldValues() available. There is not patch for this. Fieldable entity is for Drupal 7.

Option 2: extend from Node. The latest patch for this option is #10. It passes tests and solve the problem. However, it is incomplete, and needs a field added and test. Refer to the comment for details.

Remaining tasks

Decide on option
Write patch
test
review etc

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joachim created an issue. See original summary.

quietone’s picture

Or extend it from Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase\FieldableEntity and then have the methods getFields() and getFieldValues() available.

quietone’s picture

Status: Active » Needs review
FileSize
7.18 KB

Yes, let's extend from Node. Just needed a few tweaks.

Status: Needs review » Needs work

The last submitted patch, 3: 2937634-3.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review

It looks like the failure is due to translations, which are not enabled for product variations in the tests.

quietone’s picture

Status: Needs review » Needs work

Did some testing on a fresh install, which included Spanish.

$ drush mim --execute-dependencies d6_language_content_settings
 [notice] Processed 5 items (2 created, 0 updated, 0 failed, 3 ignored) - done with 'd6_node_type'
 [notice] Processed 3 items (3 created, 0 updated, 0 failed, 0 ignored) - done with 'd6_ubercart_product_type'
 [notice] Processed 5 items (0 created, 0 updated, 0 failed, 5 ignored) - done with 'd6_language_content_settings'
$ drush mim --execute-dependencies d6_ubercart_language_content_settings
 [notice] Processed 0 items (0 created, 0 updated, 0 failed, 0 ignored) - done with 'd6_ubercart_product_type'
 [notice] Processed 5 items (2 created, 0 updated, 0 failed, 3 ignored) - done with 'd6_ubercart_language_content_settings'

Manually enable translations for all product variation types

$ drush mim --execute-dependencies d6_ubercart_product_variation
 [notice] Processed 4 items (4 created, 0 updated, 0 failed, 0 ignored) - done with 'd6_ubercart_attribute_field'
 [notice] Processed 0 items (0 created, 0 updated, 0 failed, 0 ignored) - done with 'd6_ubercart_attribute_field'
 [notice] Processed 4 items (4 created, 0 updated, 0 failed, 0 ignored) - done with 'd6_ubercart_product_attribute'
 [notice] Processed 0 items (0 created, 0 updated, 0 failed, 0 ignored) - done with 'd6_ubercart_attribute_field'
 [notice] Processed 0 items (0 created, 0 updated, 0 failed, 0 ignored) - done with 'd6_ubercart_attribute_field'
 [notice] Processed 0 items (0 created, 0 updated, 0 failed, 0 ignored) - done with 'd6_ubercart_product_attribute'
 [notice] Processed 4 items (4 created, 0 updated, 0 failed, 0 ignored) - done with 'd6_ubercart_attribute_field_instance'
 [notice] Processed 5 items (5 created, 0 updated, 0 failed, 0 ignored) - done with 'd6_ubercart_product_variation'
v@cm {/opt/sites/d8/modules/contrib/commerce_migrate} (pvsource)$ drush mim --execute-dependencies d6_ubercart_product_variation_translation
 [notice] Processed 0 items (0 created, 0 updated, 0 failed, 0 ignored) - done with 'd6_ubercart_attribute_field'
 [notice] Processed 0 items (0 created, 0 updated, 0 failed, 0 ignored) - done with 'd6_ubercart_attribute_field'
 [notice] Processed 0 items (0 created, 0 updated, 0 failed, 0 ignored) - done with 'd6_ubercart_product_attribute'
 [notice] Processed 0 items (0 created, 0 updated, 0 failed, 0 ignored) - done with 'd6_ubercart_attribute_field'
 [notice] Processed 0 items (0 created, 0 updated, 0 failed, 0 ignored) - done with 'd6_ubercart_attribute_field'
 [notice] Processed 0 items (0 created, 0 updated, 0 failed, 0 ignored) - done with 'd6_ubercart_product_attribute'
 [notice] Processed 0 items (0 created, 0 updated, 0 failed, 0 ignored) - done with 'd6_ubercart_attribute_field_instance'
 [notice] Processed 2 items (2 created, 0 updated, 0 failed, 0 ignored) - done with 'd6_ubercart_product_variation_translation'
v@cm {/opt/sites/d8/modules/contrib/commerce_migrate} (pvsource)$ 

Checked the variation table and the translations are there, although they all have the 'default' product variation type. Hmm, there is no migration for product variation types?

quietone’s picture

Component: Code » Ubercart D6

Set component

quietone’s picture

Status: Needs work » Needs review
FileSize
21.93 KB
12.19 KB

So, what needs to happen here is for the product variation migration to be translation aware. For that to happen the following has been added; a migration for the language content settings for product variations, a migration for product variation types and a migration for product variation translations.

In testing, I learned that product variations only get a translation entry in the db when a field on the product variation is translated. Unfortunately, the current D6 test fixture does not have such a field with a translation. So maybe it would be better to extend from Fieldable entity as suggested in #2.

Status: Needs review » Needs work

The last submitted patch, 8: 2937634-8.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

quietone’s picture

Status: Needs work » Needs review
FileSize
23.32 KB
1.75 KB

And add some migrations to the tests.

quietone’s picture

Issue summary: View changes

Update the IS

Status: Needs review » Needs work

The last submitted patch, 10: 2937634-10.patch, failed testing. View results

quietone’s picture

Issue tags: +Needs reroll
quietone’s picture

Status: Needs work » Needs review
FileSize
8.93 KB
2.38 KB

Trying to reroll

Status: Needs review » Needs work

The last submitted patch, 14: 2937634-14.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
FileSize
8.93 KB
9.93 KB

Move test file to correct directory.

Status: Needs review » Needs work

The last submitted patch, 16: 2937634-14.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
FileSize
8.9 KB
9.93 KB

Silly me uploaded that same patch with the error.

Status: Needs review » Needs work

The last submitted patch, 18: 2937634-16.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
9.67 KB
792 bytes

Fix one error, the entity count.

Status: Needs review » Needs work

The last submitted patch, 20: 2937634-20.patch, failed testing. View results

quietone’s picture

Issue summary: View changes

Update IS

quietone’s picture

Status: Needs work » Needs review
FileSize
7.15 KB

This is a reroll of the first patch, in #3. Adding the cck fielk data to the row should be straightforward. The product and product variation migrations passed tests locally now so something has been fixed since Jan that affects this.

Status: Needs review » Needs work

The last submitted patch, 23: 2937634-23.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
FileSize
9.98 KB
2.83 KB

This patch has reduced the number of product variation from 7 to 5, which was a bit of a surprise. The source has 5 products, 2 of which are translated and the migration creates product variations are created for the translated products. Note the product variations are in the 'en' language which makes sense because product variation translation is not enabled.

I'm preparing locally to run the full migration and check that everything works as expected in the UI. In the meantime, here is a new patch, updating the tests. There is a reduction in the product variation entity count in the full upgrade test, adjusting the rollback test and checking that the two extra product variations are not created.

quietone’s picture

Yes, a full migration works as expected the 2 translations are there and available via the UI.

Before this patch there were 7 product variations after the migration, the extra two were not linked to a product and there was no test to confirm they did not exist. A test to do just that has been added in the patch in #25.

heddn’s picture

Status: Needs review » Reviewed & tested by the community

The changes here make sense. Tests are also aligned.

  • heddn committed f5a84d0 on 8.x-2.x authored by quietone
    Issue #2937634 by quietone, joachim, heddn: make ProductVariation...
heddn’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.