Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend Attribute Observer with new method to add additional data #64

Merged
merged 2 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 [];
}
}
Loading