From 778c683388b9aeda56b72254bb143c948314a7d8 Mon Sep 17 00:00:00 2001 From: Codencode Date: Sat, 14 Sep 2024 11:30:39 +0200 Subject: [PATCH 1/3] Added management of the 'addedByModule' field in the 'CustomizationField' object In the ProductFormDataProvider::extractCustomizationsData() method, I added the 'addedByModule' key to the $fields array. In the CustomizationFieldsCommandsBuilder::buildCustomizationFields() method, I added the 'added_by_module' key to the $customizationFields array. --- .../Product/CustomizationFieldsCommandsBuilder.php | 2 +- .../IdentifiableObject/DataProvider/ProductFormDataProvider.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Core/Form/IdentifiableObject/CommandBuilder/Product/CustomizationFieldsCommandsBuilder.php b/src/Core/Form/IdentifiableObject/CommandBuilder/Product/CustomizationFieldsCommandsBuilder.php index 5de266048478c..091ce84c86b48 100644 --- a/src/Core/Form/IdentifiableObject/CommandBuilder/Product/CustomizationFieldsCommandsBuilder.php +++ b/src/Core/Form/IdentifiableObject/CommandBuilder/Product/CustomizationFieldsCommandsBuilder.php @@ -74,7 +74,7 @@ private function buildCustomizationFields(array $customizationsFormData): array 'type' => (int) $customization['type'], 'localized_names' => $customization['name'], 'is_required' => (bool) $customization['required'], - 'added_by_module' => false, + 'added_by_module' => isset($customization['addedByModule']) ? (bool) $customization['addedByModule'] : false, 'id' => isset($customization['id']) ? (int) $customization['id'] : null, ]; } diff --git a/src/Core/Form/IdentifiableObject/DataProvider/ProductFormDataProvider.php b/src/Core/Form/IdentifiableObject/DataProvider/ProductFormDataProvider.php index a228400cf156c..a08f6c1c2da8f 100644 --- a/src/Core/Form/IdentifiableObject/DataProvider/ProductFormDataProvider.php +++ b/src/Core/Form/IdentifiableObject/DataProvider/ProductFormDataProvider.php @@ -616,6 +616,7 @@ private function extractCustomizationsData(ProductForEditing $productForEditing, 'name' => $customizationField->getLocalizedNames(), 'type' => $customizationField->getType(), 'required' => $customizationField->isRequired(), + 'addedByModule' => $customizationField->isAddedByModule() ]; } From e5e1761314070bdbcb4e051fc493276e90097408 Mon Sep 17 00:00:00 2001 From: Codencode Date: Sat, 14 Sep 2024 12:01:53 +0200 Subject: [PATCH 2/3] Update UnitTest --- .../DataProvider/ProductFormDataProviderTest.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/Unit/Core/Form/IdentifiableObject/DataProvider/ProductFormDataProviderTest.php b/tests/Unit/Core/Form/IdentifiableObject/DataProvider/ProductFormDataProviderTest.php index d578fc3796045..d8ff22595fb82 100644 --- a/tests/Unit/Core/Form/IdentifiableObject/DataProvider/ProductFormDataProviderTest.php +++ b/tests/Unit/Core/Form/IdentifiableObject/DataProvider/ProductFormDataProviderTest.php @@ -1008,12 +1008,14 @@ private function getDatasetsForCustomizations(): array 'name' => $localizedNames, 'type' => 1, 'required' => false, + 'addedByModule' => false, ], [ 'id' => 2, 'name' => $localizedNames, 'type' => 0, 'required' => true, + 'addedByModule' => false, ], ], ]; @@ -1024,12 +1026,14 @@ private function getDatasetsForCustomizations(): array 'name' => $localizedNames, 'type' => CustomizationFieldType::TYPE_TEXT, 'required' => false, + 'addedByModule' => false, ], [ 'id' => 2, 'name' => $localizedNames, 'type' => CustomizationFieldType::TYPE_FILE, 'required' => true, + 'addedByModule' => false, ], ]; From 5649df11c357b6c2b98d75b0d133c8b3a34f28b1 Mon Sep 17 00:00:00 2001 From: Codencode Date: Sat, 14 Sep 2024 19:01:43 +0200 Subject: [PATCH 3/3] Update ProductFormDataProvider.php --- .../IdentifiableObject/DataProvider/ProductFormDataProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Core/Form/IdentifiableObject/DataProvider/ProductFormDataProvider.php b/src/Core/Form/IdentifiableObject/DataProvider/ProductFormDataProvider.php index a08f6c1c2da8f..aa6e6d22c5b8b 100644 --- a/src/Core/Form/IdentifiableObject/DataProvider/ProductFormDataProvider.php +++ b/src/Core/Form/IdentifiableObject/DataProvider/ProductFormDataProvider.php @@ -616,7 +616,7 @@ private function extractCustomizationsData(ProductForEditing $productForEditing, 'name' => $customizationField->getLocalizedNames(), 'type' => $customizationField->getType(), 'required' => $customizationField->isRequired(), - 'addedByModule' => $customizationField->isAddedByModule() + 'addedByModule' => $customizationField->isAddedByModule(), ]; }