feat(attributes-import): import product attributes from shopPRO API into personalization

extractPersonalization() now reads both 'attributes' and 'custom_fields' fields
from the shopPRO API response, joining non-empty values with newline separator.
Previously only custom_fields was imported, causing product attributes like
"Woreczek jutowy", "Kolor koperty", "Zakrętka" to be lost during sync.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-07 08:21:38 +02:00
parent 278f44b360
commit 6d0905d97a
7 changed files with 254 additions and 19 deletions

View File

@@ -589,16 +589,21 @@ final class ShopproOrderMapper
*/
private function extractPersonalization(array $row): ?string
{
$raw = $this->readPath($row, ['custom_fields']);
if ($raw === null || $raw === '' || $raw === false) {
return null;
$parts = [];
foreach (['attributes', 'custom_fields'] as $field) {
$raw = $this->readPath($row, [$field]);
if ($raw === null || $raw === '' || $raw === false) {
continue;
}
$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);
if ($text !== '') {
$parts[] = $text;
}
}
$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;
return $parts !== [] ? implode("\n", $parts) : null;
}
/**