Don't hard-code migration names in PHP

Created on 4 February 2022, almost 3 years ago
Updated 21 April 2024, 8 months ago

Problem/Motivation

The CommerceCustomerProfileReference.php and CommerceLineItemReference.php field plugins specify migration lookups by name for their respective types of fields. If the migrations have been customized and renamed, then a variety of confusing and misleading error messages result. It does not appear to be possible to override the field plugins with custom config.

Additionally, the CommercePrice process plugin makes some unwarranted assumptions about the subfields that will be present in incoming data, making it less useful than it could be for processing price fields.

Steps to reproduce

Make a copy of the commerce1_profile.yml and/or commerce1_order_item.yml files to local config and rename them. Run these migrations. Now attempt to run the commerce1_order migration (or a renamed copy of it). You will see error messages ranging from "CommercePrice input array is invalid for destination" ( https://www.drupal.org/project/commerce_migrate/issues/3262545 β†’ ) to "Trying to access array offset on value of type null CommerceReferenceRevision.php" ( https://www.drupal.org/project/commerce_migrate/issues/3262556 β†’ ). If you go on and run a payment migration, you will find that the decimal points on the payments are in the wrong place ( https://www.drupal.org/project/commerce_migrate/issues/3233594 πŸ› Payments from Commerce 1 have wrong decimal place Fixed ).

Proposed resolution

Disable the field plugins and configure the processing of the fields in config instead, where it can be customized. Add some extra sanity checks to CommercePrice so it can be used more flexibly in config.

πŸ› Bug report
Status

Needs review

Version

4.0

Component

Drupal Commerce 1.x

Created by

πŸ‡ΊπŸ‡ΈUnited States BenStallings

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

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024