8 use \Magento\Framework\Api\AttributeValueFactory;
53 parent::__construct(
$data);
54 if (isset(
$data[self::EXTENSION_ATTRIBUTES_KEY]) && is_array(
$data[self::EXTENSION_ATTRIBUTES_KEY])) {
55 $this->populateExtensionAttributes(
$data[self::EXTENSION_ATTRIBUTES_KEY]);
67 return isset($this->_data[self::CUSTOM_ATTRIBUTES])
95 throw new \LogicException(
'Custom Attribute array elements can only be type of AttributeValue');
118 $attribute = $this->attributeValueFactory->create();
120 ->setValue($attributeValue);
135 return $this->customAttributesCodes ?? [];
149 $customAttributesMetadata = $metadataService->getCustomAttributesMetadata(get_class($this));
150 if (is_array($customAttributesMetadata)) {
152 foreach ($customAttributesMetadata as
$attribute) {
166 if (!$this->
_get(self::EXTENSION_ATTRIBUTES_KEY)) {
167 $this->populateExtensionAttributes([]);
169 return $this->
_get(self::EXTENSION_ATTRIBUTES_KEY);
178 private function populateExtensionAttributes(array $extensionAttributesData = [])
180 $extensionAttributes = $this->extensionFactory->create(get_class($this), $extensionAttributesData);
_setExtensionAttributes(\Magento\Framework\Api\ExtensionAttributesInterface $extensionAttributes)
const CUSTOM_ATTRIBUTES_KEY
getCustomAttribute($attributeCode)
const EXTENSION_ATTRIBUTES_KEY
setCustomAttribute($attributeCode, $attributeValue)
__construct(\Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $attributeValueFactory, $data=[])
getCustomAttributesCodes()
_getExtensionAttributes()
setCustomAttributes(array $attributes)