Migration ignore commerce1_product_variation_product

Created on 7 February 2024, 10 months ago
Updated 14 April 2024, 7 months ago

Problem/Motivation

I’m encountering an issue with upgrade_commerce1_product_variation_product_rfq during a commerce migration using Upgrade Migrate module. I’m facing the following error in the console:

[warning] Undefined array key 0 ProductVariations.php:70
[warning] Trying to access array offset on value of type null ProductVariations.php:70
[error] TypeError: CommerceGuys\Intl\Currency\CurrencyRepository::get(): Argument #1 ($currencyCode) must be of type string, null given, called in /Users/mymac/sites/d9_migration/web/modules/contrib/commerce_migrate/modules/commerce/src/Plugin/migrate/source/commerce1/ProductVariations.php on line 71 in CommerceGuys\Intl\Currency\CurrencyRepository->get() (line 79 of /mymac/sites/d9_migration/vendor/commerceguys/intl/src/Currency/CurrencyRepository.php) #0 /mymac/sites/d9_migration/web/modules/contrib/commerce_migrate/modules/commerce/src/Plugin/migrate/source/commerce1/ProductVariations.php(71): CommerceGuys\Intl\Currency\CurrencyRepository->get(NULL)

Steps to reproduce

To work around this, I hardcoded the currency code in ProductVariations.php as USD, since that’s the only currency used in my store:

$default_currency_code = 'USD';
$currency_code = !empty($value) && !empty($value[0]['currency_code']) ? $value[0]['currency_code'] : $default_currency_code;

However, when I run the migration to dump $row drush migrate:import upgrade_commerce1_product_variation_product_rfq --limit="10":

dump($row);
return parent::prepareRow($row);

It seems to ignore the product variations,
also this is dump output of product_variation_product_rfq:

Drupal\migrate\Row {#3659
 #source: array:24 [
  "product_id" => "4784"
  "revision_id" => "4784"
  "sku" => "ER-M-035-MF-ermfoil"
  "title" => "(3N5) 99.95% Erbium Microfoil"
  "type" => "product_rfq"
  "language" => "und"
  "uid" => "0"
  "status" => "1"
  "created" => "1437176022"
  "changed" => "1567801979"
  "data" => "b:0;"
  "migrate_map_sourceid1" => null
  "migrate_map_source_row_status" => null
  "key" => "migrate"
  "plugin" => "commerce1_product"
  "product_variation_type" => "product_rfq"
  "commerce_price" => array:1 [
   0 => array:1 [
    "fraction_digits" => 2
   ]
  ]
  "field_purity_rfq_" => []
  "field_product_code_rfq" => []
  "field_description_rfq" => []
  "commerce_stock" => []
  "field_shipping_weight" => []
  "field_shipping_dimensions" => []
  "field_impurity" => []
 ]
 #sourceIds: array:1 [
  "product_id" => array:2 [
   "type" => "integer"
   "alias" => "p"
  ]
 ]
 #destination: []
 #idMap: array:3 [
  "original_hash" => ""
  "hash" => ""
  "source_row_status" => 1
 ]
 #frozen: false
 #rawDestination: []
 #isStub: false
 #emptyDestinationProperties: []
}

[notice] Processed 10 items (0 created, 0 updated, 0 failed, 10 ignored) - done with 'upgrade_commerce1_product_variation_product_rfq'

Any suggestions, help, or patches would be greatly appreciated. Thank you!

🐛 Bug report
Status

Needs work

Version

4.0

Component

Drupal Commerce 1.x

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @naveed_jadoon
  • In the ignored product variation, the commerce_price array only has fraction_digits without amount and currency_code, which are essential for the price field. The successful migration has a complete commerce_price array including amount, currency_code, and data.
    and i can see these values in d7 DB the screenshots are attached for the ignored product, but still the migration ignore this

  • Status changed to Needs work 8 months ago
  • I’m facing a series of issues during the Drupal 7 commerce migration, specifically related to node-type products and the migration process. Here are the details:
    In Drupal 7, the product type is referenced in the content type correctly. However, during the migration D9, the field instance is incorrectly referencing a content type instead of the expected product reference.
    When I initiate the migration using the command --execute-dependencies, the process halts with the following error messages
    when it reaches upgrade_commerce1_product_variation_product

    Undefined array key 0 in ProductVariations.php:70
    [warning] Trying to access array offset on the value of type null in ProductVariations.php:70
    [error] TypeError: Argument #1 ($currencyCode) must be of type string, null given in CurrencyRepository.php:79

    The migration also ignores the upgrade_commerce1_product_attribute This indicates that the “currency code” isn’t being recognized, and skips all other product variations field data.
    After some research, I discovered a related issue on Drupal.org ( https://www.drupal.org/project/commerce_migrate/issues/2959614 🐛 Products displays Nodes Needs work ) and applied the latest patch. However, attempting to run the command
    drush migrate-upgrade --legacy-db-key=migrate --legacy-root=http://localhost/drupal7/ --configure-only results in an error about a missing use Drupal\migrate\MigrateException;.

    Adding the missing line

    use Drupal\migrate\MigrateException;
    

    in MigratePrepareRow.php seemingly fixed that issue, but a new problem arose when I ran the command
    drush migrate-upgrade --legacy-db-key=migrate --legacy-root=http://localhost/drupal7/ --configure-only

    [warning] Undefined property: Drupal\commerce_migrate_commerce\EventSubscriber\MigratePrepareRow::$configuration in MigratePrepareRow.php:161
    [error] A product variation type could not be determined for the product type: commerce_product_reference

    This suggests there’s still an unresolved issue with product variation types during migration.

  • 🇳🇿New Zealand quietone

    @naveed_jadoon, thanks for the report and the ongoing analysis!

    There are two issues about the lack of a currency code, [3292930] and 🐛 commerce1 payment transaction with empty currency_code crashes migrate Needs review that may help. Having you input on the best way to solve that is welcome. I suggest asking in Drupal Slack, #migration or perhaps #commerce for support.

    I have also changed the status. While I appreciate the challenges you are facing Drupal does have definitions for the various values in the issue meta data. There is information in the handbook for the the priority field .

Production build 0.71.5 2024