This commit is contained in:
2026-04-02 00:17:46 +02:00
parent 34b0a2b4f5
commit 39c318382a
14 changed files with 417 additions and 16 deletions

View File

@@ -256,11 +256,11 @@ final class OrderImportRepository
'INSERT INTO order_items (
order_id, source_item_id, external_item_id, ean, sku, original_name, original_code,
original_price_with_tax, original_price_without_tax, media_url, quantity, tax_rate, item_status,
unit, item_type, source_product_id, source_product_set_id, sort_order, payload_json
unit, item_type, source_product_id, source_product_set_id, sort_order, payload_json, personalization
) VALUES (
:order_id, :source_item_id, :external_item_id, :ean, :sku, :original_name, :original_code,
:original_price_with_tax, :original_price_without_tax, :media_url, :quantity, :tax_rate, :item_status,
:unit, :item_type, :source_product_id, :source_product_set_id, :sort_order, :payload_json
:unit, :item_type, :source_product_id, :source_product_set_id, :sort_order, :payload_json, :personalization
)'
);
@@ -285,6 +285,7 @@ final class OrderImportRepository
'source_product_set_id' => $row['source_product_set_id'] ?? null,
'sort_order' => (int) ($row['sort_order'] ?? 0),
'payload_json' => $this->encodeJson($row['payload_json'] ?? null),
'personalization' => $row['personalization'] ?? null,
]);
}
}

View File

@@ -71,7 +71,7 @@ final class ShopproOrderMapper
$sourceOrderId = $fallbackOrderId;
}
$sourceCreatedAt = StringHelper::normalizeDateTime((string) $this->readPath($payload, ['created_at', 'date_created', 'date_add']));
$sourceCreatedAt = StringHelper::normalizeDateTime((string) $this->readPath($payload, ['created_at', 'date_created', 'date_add', 'date_order']));
$sourceUpdatedAt = StringHelper::normalizeDateTime((string) $this->readPath($payload, ['updated_at', 'date_updated', 'modified_at', 'date_modified', 'created_at']));
if ($sourceUpdatedAt === null) {
$sourceUpdatedAt = $fallbackUpdatedAt !== '' ? $fallbackUpdatedAt : date('Y-m-d H:i:s');
@@ -577,12 +577,30 @@ final class ShopproOrderMapper
'source_product_set_id' => StringHelper::nullableString((string) ($parentProductId > 0 ? $parentProductId : '')),
'sort_order' => $sort++,
'payload_json' => $row,
'personalization' => $this->extractPersonalization($row),
];
}
return $result;
}
/**
* @param array<string, mixed> $row
*/
private function extractPersonalization(array $row): ?string
{
$raw = $this->readPath($row, ['custom_fields']);
if ($raw === null || $raw === '' || $raw === false) {
return null;
}
$text = str_replace(['<br>', '<br/>', '<br />'], "\n", (string) $raw);
$text = html_entity_decode(strip_tags($text), ENT_QUOTES | ENT_HTML5, 'UTF-8');
$text = trim($text);
return $text !== '' ? $text : null;
}
/**
* @param array<string, mixed> $payload
* @return array<int, array<string, mixed>>