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

@@ -0,0 +1,101 @@
---
phase: 71-attributes-import
plan: 01
subsystem: api
tags: [shoppro, sync, personalization, attributes]
requires:
- phase: 63-order-item-personalization
provides: personalization column and extractPersonalization method
provides:
- Import pola attributes z API shopPRO do personalizacji produktow
affects: []
tech-stack:
added: []
patterns: [multi-field extraction loop in extractPersonalization]
key-files:
created: []
modified: [src/Modules/Settings/ShopproOrderMapper.php]
key-decisions:
- "attributes first, custom_fields second — kolejnosc laczenia pol"
- "Jednorazowa naprawa 36 istniejacych pozycji w bazie produkcyjnej"
patterns-established: []
duration: 15min
started: 2026-04-07T12:00:00Z
completed: 2026-04-07T12:15:00Z
---
# Phase 71 Plan 01: Attributes Import Summary
**Rozszerzenie extractPersonalization() o pole `attributes` z API shopPRO — atrybuty produktow (kolor, wariant, woreczek jutowy) sa teraz importowane obok custom_fields.**
## Performance
| Metric | Value |
|--------|-------|
| Duration | ~15min |
| Tasks | 1 completed |
| Files modified | 1 |
## Acceptance Criteria Results
| Criterion | Status | Notes |
|-----------|--------|-------|
| AC-1: Atrybuty importowane do personalizacji | Pass | "Woreczek jutowy: Nie" poprawnie parsowane |
| AC-2: Polaczenie attributes + custom_fields | Pass | Oba pola laczone separatorem \n |
| AC-3: Puste pola bez pustych linii | Pass | Puste attributes pomijane |
| AC-4: Oba puste zwracaja null | Pass | Zachowanie kompatybilne wstecz |
## Accomplishments
- Rozszerzono `extractPersonalization()` o iteracje po `['attributes', 'custom_fields']`
- Naprawiono 36 istniejacych pozycji w bazie produkcyjnej jednorazowym skryptem
- Zweryfikowano 0 brakujacych pozycji po naprawie (pelne pokrycie)
## Files Created/Modified
| File | Change | Purpose |
|------|--------|---------|
| `src/Modules/Settings/ShopproOrderMapper.php` | Modified | extractPersonalization() czyta attributes + custom_fields |
## Decisions Made
| Decision | Rationale | Impact |
|----------|-----------|--------|
| attributes przed custom_fields | Atrybuty to metadane produktu (wariant), personalizacja to tresc klienta — logiczna kolejnosc | Sposob wyswietlania w UI |
| Jednorazowa naprawa danych w DB | payload_json przechowuje oryginalne dane — mozna przeliczyc personalizacje | 36 pozycji naprawionych bez resyncu |
## Deviations from Plan
### Summary
| Type | Count | Impact |
|------|-------|--------|
| Scope additions | 1 | Pozytywny — naprawiono dane historyczne |
**Dodatkowa naprawa:** Poza planem wykonano jednorazowy update 36 istniejacych pozycji w bazie produkcyjnej, ktore mialy attributes w payload_json ale pusta personalizacje. Nie wymagalo zmian w kodzie.
## Issues Encountered
None
## Next Phase Readiness
**Ready:**
- Nowe zamowienia beda importowane z pelna personalizacja (po deploy)
- Historyczne dane juz naprawione
**Concerns:**
- Kod wymaga deploy na serwer (FTP) aby nowe importy dzialaly poprawnie
**Blockers:**
- None
---
*Phase: 71-attributes-import, Plan: 01*
*Completed: 2026-04-07*