/**
  * Get attribute model by attribute data object
  *
  * @param string $entityType
  * @param AttributeMetadataInterface $attribute
  * @return Attribute
  * @throws NoSuchEntityException
  */
 public function getModelByAttribute($entityType, AttributeMetadataInterface $attribute)
 {
     /** @var Attribute $model */
     $model = $this->attributeMetadataDataProvider->getAttribute($entityType, $attribute->getAttributeCode());
     if ($model) {
         return $model;
     } else {
         throw new NoSuchEntityException(__(NoSuchEntityException::MESSAGE_DOUBLE_FIELDS, ['fieldName' => 'entityType', 'fieldValue' => $entityType, 'field2Name' => 'attributeCode', 'field2Value' => $attribute->getAttributeCode()]));
     }
 }
 /**
  * {@inheritdoc}
  */
 public function getAttributeMetadata($attributeCode)
 {
     /** @var AbstractAttribute $attribute */
     $attribute = $this->attributeMetadataDataProvider->getAttribute(self::ENTITY_TYPE_CUSTOMER, $attributeCode);
     if ($attribute && ($attributeCode === 'id' || $attribute->getId() !== null)) {
         $attributeMetadata = $this->attributeMetadataConverter->createMetadataAttribute($attribute);
         return $attributeMetadata;
     } else {
         throw new NoSuchEntityException(__(NoSuchEntityException::MESSAGE_DOUBLE_FIELDS, ['fieldName' => 'entityType', 'fieldValue' => self::ENTITY_TYPE_CUSTOMER, 'field2Name' => 'attributeCode', 'field2Value' => $attributeCode]));
     }
 }
예제 #3
0
 /**
  * {@inheritdoc}
  */
 public function getAttributeMetadata($attributeCode)
 {
     /** @var AbstractAttribute $attribute */
     $attribute = $this->attributeMetadataDataProvider->getAttribute(AddressMetadataInterface::ENTITY_TYPE_ADDRESS, $attributeCode);
     if ($attribute && ($attributeCode === 'id' || $attribute->getId() !== null)) {
         $attributeMetadata = $this->attributeMetadataConverter->createMetadataAttribute($attribute);
         return $attributeMetadata;
     } else {
         throw new NoSuchEntityException(__('No such entity with %fieldName = %fieldValue, %field2Name = %field2Value', ['fieldName' => 'entityType', 'fieldValue' => AddressMetadataInterface::ENTITY_TYPE_ADDRESS, 'field2Name' => 'attributeCode', 'field2Value' => $attributeCode]));
     }
 }