From 556da6e451cfa72971397af62f0d5836637f723f Mon Sep 17 00:00:00 2001 From: Matthieu Date: Fri, 13 Mar 2026 11:20:28 +0100 Subject: [PATCH] fix(custom-fields) : include customFields and customFieldValues in product normalization normalizeProduct() had customFields hardcoded to [] and was missing customFieldValues entirely, unlike normalizeComposant and normalizePiece. Co-Authored-By: Claude Opus 4.6 --- src/Controller/MachineStructureController.php | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/Controller/MachineStructureController.php b/src/Controller/MachineStructureController.php index 70d9250..20c8d1c 100644 --- a/src/Controller/MachineStructureController.php +++ b/src/Controller/MachineStructureController.php @@ -711,6 +711,7 @@ class MachineStructureController extends AbstractController $pieces = []; foreach ($composant->getPieceSlots() as $slot) { $pieceData = [ + 'slotId' => $slot->getId(), 'typePieceId' => $slot->getTypePiece()?->getId(), 'quantity' => $slot->getQuantity(), 'selectedPieceId' => $slot->getSelectedPiece()?->getId(), @@ -769,16 +770,19 @@ class MachineStructureController extends AbstractController private function normalizeProduct(Product $product): array { + $type = $product->getTypeProduct(); + return [ - 'id' => $product->getId(), - 'name' => $product->getName(), - 'reference' => $product->getReference(), - 'supplierPrice' => $product->getSupplierPrice(), - 'typeProductId' => $product->getTypeProduct()?->getId(), - 'typeProduct' => $this->normalizeModelType($product->getTypeProduct()), - 'constructeurs' => $this->normalizeConstructeurs($product->getConstructeurs()), - 'documents' => [], - 'customFields' => [], + 'id' => $product->getId(), + 'name' => $product->getName(), + 'reference' => $product->getReference(), + 'supplierPrice' => $product->getSupplierPrice(), + 'typeProductId' => $type?->getId(), + 'typeProduct' => $this->normalizeModelType($type), + 'constructeurs' => $this->normalizeConstructeurs($product->getConstructeurs()), + 'documents' => [], + 'customFields' => $type ? $this->normalizeCustomFieldDefinitions($type->getProductCustomFields()) : [], + 'customFieldValues' => $this->normalizeCustomFieldValues($product->getCustomFieldValues()), ]; }