From 5b60f23a8057bcdd2a0fcc89fd05987347c6bc51 Mon Sep 17 00:00:00 2001 From: Kenza Yamlahi Date: Mon, 27 Nov 2023 17:33:05 +0100 Subject: [PATCH 1/2] Extend Attribute Observer with new method to add additional data --- CHANGELOG.md | 6 ++++ src/Observers/AttributeObserver.php | 46 ++++++++++++++++++----------- 2 files changed, 35 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3dcb63f..ac926fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# Version 22.0.8 + +## Feature + +* Extend Attribute Observer with new method to add additional fields. + # Version 22.0.7 ## Bugfixes diff --git a/src/Observers/AttributeObserver.php b/src/Observers/AttributeObserver.php index 5031c76..478b5b5 100644 --- a/src/Observers/AttributeObserver.php +++ b/src/Observers/AttributeObserver.php @@ -98,23 +98,27 @@ protected function prepareAttributes() // return the prepared product return $this->initializeEntity( - array( - MemberNames::ENTITY_TYPE_ID => $entityTypeId, - MemberNames::ATTRIBUTE_CODE => $attributeCode, - MemberNames::ATTRIBUTE_MODEL => $attributeModel, - MemberNames::BACKEND_MODEL => $backendModel, - MemberNames::BACKEND_TYPE => $backendType, - MemberNames::BACKEND_TABLE => $backendTable, - MemberNames::FRONTEND_MODEL => $frontendModel, - MemberNames::FRONTEND_INPUT => $frontendInput, - MemberNames::FRONTEND_LABEL => $frontendLabel, - MemberNames::FRONTEND_CLASS => $frontendClass, - MemberNames::SOURCE_MODEL => $sourceModel, - MemberNames::IS_REQUIRED => $isRequired, - MemberNames::IS_USER_DEFINED => $isUserDefined, - MemberNames::DEFAULT_VALUE => null, - MemberNames::IS_UNIQUE => $isUnique, - MemberNames::NOTE => $note + array_merge( + array( + MemberNames::ENTITY_TYPE_ID => $entityTypeId, + MemberNames::ATTRIBUTE_CODE => $attributeCode, + MemberNames::ATTRIBUTE_MODEL => $attributeModel, + MemberNames::BACKEND_MODEL => $backendModel, + MemberNames::BACKEND_TYPE => $backendType, + MemberNames::BACKEND_TABLE => $backendTable, + MemberNames::FRONTEND_MODEL => $frontendModel, + MemberNames::FRONTEND_INPUT => $frontendInput, + MemberNames::FRONTEND_LABEL => $frontendLabel, + MemberNames::FRONTEND_CLASS => $frontendClass, + MemberNames::SOURCE_MODEL => $sourceModel, + MemberNames::IS_REQUIRED => $isRequired, + MemberNames::IS_USER_DEFINED => $isUserDefined, + MemberNames::DEFAULT_VALUE => null, + MemberNames::IS_UNIQUE => $isUnique, + MemberNames::NOTE => $note + ), + $this->additionalAttributeFields() + ) ); } @@ -201,4 +205,12 @@ protected function getEntityType($entityTypeCode) { return $this->getSubject()->getEntityType($entityTypeCode); } + + /** + * @return array + */ + protected function additionalAttributeFields(): array + { + return []; + } } From 2d2bfcd40bf3476ff38f3614523aec554e741bfa Mon Sep 17 00:00:00 2001 From: Kenza Yamlahi Date: Tue, 28 Nov 2023 10:42:06 +0100 Subject: [PATCH 2/2] FIX static test issue --- src/Observers/AttributeObserver.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Observers/AttributeObserver.php b/src/Observers/AttributeObserver.php index 478b5b5..f216dd6 100644 --- a/src/Observers/AttributeObserver.php +++ b/src/Observers/AttributeObserver.php @@ -118,7 +118,6 @@ protected function prepareAttributes() MemberNames::NOTE => $note ), $this->additionalAttributeFields() - ) ); }