Skip to content

Instantly share code, notes, and snippets.

@junaidpv
Created September 16, 2022 15:05
Show Gist options
  • Save junaidpv/e7715e4d63062c184571d31af69b5685 to your computer and use it in GitHub Desktop.
Save junaidpv/e7715e4d63062c184571d31af69b5685 to your computer and use it in GitHub Desktop.
Patch for the commerce_migrate to fIx migraiton error when there is not order component present.
diff --git a/modules/commerce/src/Plugin/migrate/process/commerce1/OrderItemDiscountAdjustment.php b/modules/commerce/src/Plugin/migrate/process/commerce1/OrderItemDiscountAdjustment.php
index 3ece971..45fb789 100644
--- a/modules/commerce/src/Plugin/migrate/process/commerce1/OrderItemDiscountAdjustment.php
+++ b/modules/commerce/src/Plugin/migrate/process/commerce1/OrderItemDiscountAdjustment.php
@@ -116,7 +116,7 @@ class OrderItemDiscountAdjustment extends CommercePrice implements ContainerFact
// Find all price components on the order, not the line item, that are not
// a shipping type and not also in the line item price components.
- $order_components = $row->getSourceProperty('order_components/0/data/components');
+ $order_components = $row->getSourceProperty('order_components/0/data/components') ?? [];
$order_names = [];
foreach ($order_components as $order_component) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment