Skip to content

Commit

Permalink
Merge pull request #64 from techdivision/pac-5
Browse files Browse the repository at this point in the history
Extend Attribute Observer with new method to add additional data
  • Loading branch information
kenza-ya authored Nov 28, 2023
2 parents 953b0d8 + 2d2bfcd commit ed341ec
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 17 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Version 22.0.8

## Feature

* Extend Attribute Observer with new method to add additional fields.

# Version 22.0.7

## Bugfixes
Expand Down
45 changes: 28 additions & 17 deletions src/Observers/AttributeObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,23 +98,26 @@ 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()
)
);
}
Expand Down Expand Up @@ -201,4 +204,12 @@ protected function getEntityType($entityTypeCode)
{
return $this->getSubject()->getEntityType($entityTypeCode);
}

/**
* @return array
*/
protected function additionalAttributeFields(): array
{
return [];
}
}

0 comments on commit ed341ec

Please sign in to comment.