diff --git a/autoload/Domain/Product/ProductRepository.php b/autoload/Domain/Product/ProductRepository.php index f0dd1e8..a538629 100644 --- a/autoload/Domain/Product/ProductRepository.php +++ b/autoload/Domain/Product/ProductRepository.php @@ -654,6 +654,10 @@ class ProductRepository 'custom_label_2' => $product['custom_label_2'], 'custom_label_3' => $product['custom_label_3'], 'custom_label_4' => $product['custom_label_4'], + 'new_to_date' => $product['new_to_date'], + 'additional_message' => (int)($product['additional_message'] ?? 0), + 'additional_message_required' => (int)($product['additional_message_required'] ?? 0), + 'additional_message_text' => $product['additional_message_text'], 'set_id' => $product['set_id'] !== null ? (int)$product['set_id'] : null, 'product_unit_id' => $product['product_unit_id'] !== null ? (int)$product['product_unit_id'] : null, 'producer_id' => $product['producer_id'] !== null ? (int)$product['producer_id'] : null, diff --git a/autoload/api/Controllers/ProductsApiController.php b/autoload/api/Controllers/ProductsApiController.php index 9b8c48b..1b91c11 100644 --- a/autoload/api/Controllers/ProductsApiController.php +++ b/autoload/api/Controllers/ProductsApiController.php @@ -437,7 +437,7 @@ class ProductsApiController // String fields — direct mapping $stringFields = [ 'sku', 'ean', 'custom_label_0', 'custom_label_1', 'custom_label_2', - 'custom_label_3', 'custom_label_4', 'wp', + 'custom_label_3', 'custom_label_4', 'wp', 'new_to_date', 'additional_message_text', ]; foreach ($stringFields as $field) { if (isset($body[$field])) { @@ -447,6 +447,18 @@ class ProductsApiController } } + if (isset($body['additional_message'])) { + $d['additional_message'] = !empty($body['additional_message']) ? 'on' : ''; + } elseif ($existing !== null) { + $d['additional_message'] = !empty($existing['additional_message']) ? 'on' : ''; + } + + if (isset($body['additional_message_required'])) { + $d['additional_message_required'] = !empty($body['additional_message_required']) ? 'on' : ''; + } elseif ($existing !== null) { + $d['additional_message_required'] = !empty($existing['additional_message_required']) ? 'on' : ''; + } + // Foreign keys if (isset($body['set_id'])) { $d['set'] = $body['set_id']; diff --git a/docs/API.md b/docs/API.md index 5f4a221..5688e19 100644 --- a/docs/API.md +++ b/docs/API.md @@ -216,6 +216,10 @@ Odpowiedz: "weight": 0.5, "stock_0_buy": 0, "custom_label_0": null, + "new_to_date": null, + "additional_message": 0, + "additional_message_required": 0, + "additional_message_text": null, "set_id": null, "product_unit_id": 1, "producer_id": 3, @@ -294,6 +298,10 @@ Content-Type: application/json "status": 1, "sku": "PROD-001", "ean": "5901234123457", + "new_to_date": null, + "additional_message": 0, + "additional_message_required": 0, + "additional_message_text": null, "weight": 0.5, "languages": { "pl": { @@ -330,6 +338,10 @@ Content-Type: application/json { "price_brutto": 129.99, "status": 1, + "new_to_date": "2026-12-31", + "additional_message": 1, + "additional_message_required": 0, + "additional_message_text": "Dodaj tresc do personalizacji", "languages": { "pl": { "name": "Zaktualizowana nazwa" @@ -339,6 +351,7 @@ Content-Type: application/json ``` Partial update — wystarczy przeslac tylko zmienione pola. Pola nieprzeslane zachowuja aktualna wartosc. +Pola ustawien produktu obslugiwane przez API: `new_to_date`, `additional_message`, `additional_message_required`, `additional_message_text`. Odpowiedz: pelne dane produktu (jak w `get`). diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 365c0cb..fb51540 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -4,6 +4,14 @@ Logi zmian z migracji na Domain-Driven Architecture. Najnowsze na gorze. --- +## ver. 0.332 (2026-03-01) - API produktów: nowe pola new_to_date i additional_message + +- **NEW**: `ProductRepository::getProductForApi()` — eksportuje 4 nowe pola: `new_to_date`, `additional_message` (int 0/1), `additional_message_required` (int 0/1), `additional_message_text` +- **NEW**: `ProductsApiController` — obsługa nowych pól w PUT/PATCH (aktualizacja `new_to_date`, `additional_message`, `additional_message_required`, `additional_message_text`) +- **DOCS**: `docs/API.md` — zaktualizowane przykłady GET/PUT dla nowych pól produktu + +--- + ## ver. 0.331 (2026-03-01) - Bugfix: strona produktu używała layoutu kategorii zamiast domyślnego - **FIX**: `LayoutsRepository::getProductLayout()` — fallback gdy produkt i jego kategorie nie mają przypisanego layoutu zmieniany z `categories_default = 1` na `status = 1`; wcześniej produkty bez layoutu pobierały szablon "Podstrony - kategorie" zamiast właściwego domyślnego diff --git a/docs/TESTING.md b/docs/TESTING.md index 2b56703..54958fd 100644 --- a/docs/TESTING.md +++ b/docs/TESTING.md @@ -23,10 +23,10 @@ composer test # standard ## Aktualny stan ```text -OK (805 tests, 2253 assertions) +OK (807 tests, 2258 assertions) ``` -Zweryfikowano: 2026-02-24 (ver. 0.318) +Zweryfikowano: 2026-03-01 (ver. 0.332) ## Konfiguracja