-
Notifications
You must be signed in to change notification settings - Fork 26
fix: populate primaryOrderDeliveryId and primaryOrderTransactionId in OrderConverter #104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
fix: populate primaryOrderDeliveryId and primaryOrderTransactionId in OrderConverter #104
Conversation
MalteJanz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution 🚀
| $converted['primaryOrderDeliveryId'] = $converted['deliveries'][0]['id']; | ||
| } | ||
| if (!isset($converted['primaryOrderTransactionId']) && !empty($converted['transactions'])) { | ||
| $converted['primaryOrderTransactionId'] = $converted['transactions'][0]['id']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like PHPStan isn't happy about this, because it thinks the array has a shape of array<string,mixed> as defined here:
SwagMigrationAssistant/src/Profile/Shopware6/Converter/OrderConverter.php
Lines 104 to 109 in 5a9afd8
| $this->updateAssociationIds( | |
| $converted['transactions'], | |
| DefaultEntities::PAYMENT_METHOD, | |
| 'paymentMethodId', | |
| DefaultEntities::ORDER | |
| ); |
SwagMigrationAssistant/src/Profile/Shopware6/Converter/ShopwareConverter.php
Lines 128 to 132 in 5d4ec50
| * Replaces every id (associationIdKey) in the specified array of entities with the right mapping dependent one. | |
| * | |
| * @param array<string, mixed> $associationArray | |
| */ | |
| protected function updateAssociationIds(array &$associationArray, string $entity, string $associationIdKey, string $sourceEntity, bool $logMissing = true, bool $unsetMissing = false): void |
But like in this case, in practice it can also have integer keys. Would be nice if you could fix this to get the CI checks green 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gonna need to find some time, but going to do it :)
1. Why is this change necessary?
closes shopware/shopware#14051
The Migration Assistant does not populate the
primaryOrderDeliveryIdandprimaryOrderTransactionIdfields when migrating orders from Shopware 5 to Shopware 6. These fields were introduced in Shopware 6.7 and are required for proper order handling.2. What does this change do, exactly?
This change updates both OrderConverters to set the primary order delivery and transaction IDs:
Shopware 5 → 6 (
Profile/Shopware/Converter/OrderConverter.php): SetsprimaryOrderDeliveryIdto the first delivery's ID andprimaryOrderTransactionIdto the first transaction's ID after they are created.Shopware 6 → 6 (
Profile/Shopware6/Converter/OrderConverter.php): SetsprimaryOrderDeliveryIdandprimaryOrderTransactionIdfrom the first delivery/transaction if deliveries and transactions exist.This mirrors the behavior of Shopware 6's core
OrderConverterwhich sets these fields when converting a cart to an order.3. Describe each step to reproduce the issue or behaviour.
SELECT id, primary_order_delivery_id, primary_order_transaction_id FROM \order``NULL5. Checklist
srcfile (not strictly necessary for tests)@internal/@private