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:
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user