Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/Profile/Shopware/Converter/OrderConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,13 @@ public function convert(
$this->applyTransactions($data, $converted);
unset($data['cleared'], $data['paymentstatus']);

if (!empty($converted['deliveries'])) {
$converted['primaryOrderDeliveryId'] = $converted['deliveries'][0]['id'];
}
if (!empty($converted['transactions'])) {
$converted['primaryOrderTransactionId'] = $converted['transactions'][0]['id'];
}

$billingAddress = $this->getAddress($data['billingaddress']);
if (empty($billingAddress)) {
$this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog(
Expand Down
7 changes: 7 additions & 0 deletions src/Profile/Shopware6/Converter/OrderConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,13 @@
$converted['updatedById'] = $this->getMappingIdFacade(DefaultEntities::USER, $data['updatedById']);
}

if (!isset($converted['primaryOrderDeliveryId']) && !empty($converted['deliveries'])) {
$converted['primaryOrderDeliveryId'] = $converted['deliveries'][0]['id'];
}
if (!isset($converted['primaryOrderTransactionId']) && !empty($converted['transactions'])) {
$converted['primaryOrderTransactionId'] = $converted['transactions'][0]['id'];

Check failure on line 168 in src/Profile/Shopware6/Converter/OrderConverter.php

View workflow job for this annotation

GitHub Actions / phpstan

Offset 0 does not exist on non-empty-array<string, mixed>.
Copy link
Contributor

@MalteJanz MalteJanz Dec 19, 2025

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:

$this->updateAssociationIds(
$converted['transactions'],
DefaultEntities::PAYMENT_METHOD,
'paymentMethodId',
DefaultEntities::ORDER
);

* 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 🙂

Copy link
Author

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 :)

}

return new ConvertStruct($converted, null, $this->mainMapping['id'] ?? null);
}

Expand Down
7 changes: 7 additions & 0 deletions tests/Profile/Shopware55/Converter/OrderConverterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,13 @@ public function testConvert(): void
static::assertArrayHasKey('id', $converted);
static::assertArrayHasKey('orderCustomer', $converted);
static::assertArrayHasKey('deliveries', $converted);
static::assertArrayHasKey('transactions', $converted);
static::assertNotEmpty($converted['deliveries']);
static::assertNotEmpty($converted['transactions']);
static::assertArrayHasKey('primaryOrderDeliveryId', $converted);
static::assertArrayHasKey('primaryOrderTransactionId', $converted);
static::assertSame($converted['deliveries'][0]['id'], $converted['primaryOrderDeliveryId']);
static::assertSame($converted['transactions'][0]['id'], $converted['primaryOrderTransactionId']);
static::assertSame(TestDefaults::SALES_CHANNEL, $converted['salesChannelId']);
static::assertSame('[email protected]', $converted['orderCustomer']['email']);
static::assertCount(0, $this->loggingService->getLoggingArray());
Expand Down
2 changes: 2 additions & 0 deletions tests/_fixtures/Shopware6/Order/01-HappyCase/output.php
Original file line number Diff line number Diff line change
Expand Up @@ -435,4 +435,6 @@
'e3563b3f63c14b52a9b1dedfbc12c2fa',
],
'id' => 'efaf7e8752b242baa67ed795d18f785d',
'primaryOrderDeliveryId' => '8c6259d6e4ef44ed93ed244b349305a2',
'primaryOrderTransactionId' => 'e6e10333864f49248ecab59e481fe32e',
];
2 changes: 2 additions & 0 deletions tests/_fixtures/Shopware6/Order/02-WithoutMedia/output.php
Original file line number Diff line number Diff line change
Expand Up @@ -431,4 +431,6 @@
'e3563b3f63c14b52a9b1dedfbc12c2fa',
],
'id' => 'efaf7e8752b242baa67ed795d18f785d',
'primaryOrderDeliveryId' => '8c6259d6e4ef44ed93ed244b349305a2',
'primaryOrderTransactionId' => 'e6e10333864f49248ecab59e481fe32e',
];
2 changes: 2 additions & 0 deletions tests/_fixtures/Shopware6/Order/03-WithoutProduct/output.php
Original file line number Diff line number Diff line change
Expand Up @@ -425,4 +425,6 @@
'e3563b3f63c14b52a9b1dedfbc12c2fa',
],
'id' => 'efaf7e8752b242baa67ed795d18f785d',
'primaryOrderDeliveryId' => '8c6259d6e4ef44ed93ed244b349305a2',
'primaryOrderTransactionId' => 'e6e10333864f49248ecab59e481fe32e',
];
Original file line number Diff line number Diff line change
Expand Up @@ -437,4 +437,6 @@
'id' => 'efaf7e8752b242baa67ed795d18f785d',
'createdById' => '019270bb17fe70158f37ac83eaa7f761',
'updatedById' => '019270bb17fe70158f37ac83eaa7f762',
'primaryOrderDeliveryId' => '8c6259d6e4ef44ed93ed244b349305a2',
'primaryOrderTransactionId' => 'e6e10333864f49248ecab59e481fe32e',
];
Loading