예제 #1
0
 public function testGetCustomAttributesMetadata()
 {
     $customAttributesMetadata = $this->_service->getCustomAttributesMetadata();
     $configAttributeCode = 'stock_item';
     $configAttributeFound = false;
     foreach ($customAttributesMetadata as $attribute) {
         if ($attribute->getAttributeCode() == $configAttributeCode) {
             $configAttributeFound = true;
             break;
         }
     }
     if (!$configAttributeFound) {
         $this->fail("Custom attribute declared in the config not found.");
     }
 }
예제 #2
0
 public function testGetCustomAttributesMetadata()
 {
     $customAttributesMetadata = $this->_service->getCustomAttributesMetadata();
     $this->assertCount(32, $customAttributesMetadata, "Invalid number of attributes returned.");
     $configAttributeCode = 'category_attribute_2';
     $configAttributeFound = false;
     foreach ($customAttributesMetadata as $attribute) {
         if ($attribute->getAttributeCode() == $configAttributeCode) {
             $configAttributeFound = true;
             break;
         }
     }
     if (!$configAttributeFound) {
         $this->fail("Custom attribute declared in the config not found.");
     }
 }
예제 #3
0
 /**
  * {@inheritdoc}
  */
 public function getCustomAttributesMetadata($dataObjectClassName = null)
 {
     if (!is_null($this->customAttributesMetadataCache)) {
         return $this->customAttributesMetadataCache;
     }
     $this->customAttributesMetadataCache = $this->metadataService->getCustomAttributesMetadata();
     return $this->customAttributesMetadataCache;
 }
예제 #4
0
 /**
  * Template method used to configure the attribute codes for the custom attributes
  *
  * @return string[]
  */
 protected function getCustomAttributesCodes()
 {
     $attributeCodes = [];
     $dataObjectClassName = $this->_getDataObjectType();
     if (empty($this->customAttributesMetadata)) {
         $this->customAttributesMetadata = $this->metadataService->getCustomAttributesMetadata($dataObjectClassName);
     }
     if (is_array($this->customAttributesMetadata)) {
         foreach ($this->customAttributesMetadata as $attribute) {
             $attributeCodes[] = $attribute->getAttributeCode();
         }
     }
     return $attributeCodes;
 }
 /**
  * Template method used to configure the attribute codes for the custom attributes
  *
  * @return string[]
  */
 protected function getCustomAttributesCodes()
 {
     if (!is_null($this->customAttributesCodes)) {
         return $this->customAttributesCodes;
     }
     $attributeCodes = [];
     $customAttributesMetadata = $this->metadataService->getCustomAttributesMetadata($this->_getDataObjectType());
     if (is_array($customAttributesMetadata)) {
         foreach ($customAttributesMetadata as $attribute) {
             $attributeCodes[] = $attribute->getAttributeCode();
         }
     }
     $this->customAttributesCodes = $attributeCodes;
     return $attributeCodes;
 }
예제 #6
0
 /**
  * Template method used to configure the attribute codes for the custom attributes
  *
  * @return string[]
  */
 protected function getCustomAttributesCodes()
 {
     if (!is_null($this->customAttributesCodes)) {
         return $this->customAttributesCodes;
     }
     $attributeCodes = [];
     /** @var \Magento\Framework\Api\MetadataObjectInterface[] $customAttributesMetadata */
     $customAttributesMetadata = $this->metadataService->getCustomAttributesMetadata($this->_getDataObjectType());
     if (is_array($customAttributesMetadata)) {
         foreach ($customAttributesMetadata as $attribute) {
             $attributeCodes[] = $attribute->getAttributeCode();
         }
     }
     $this->customAttributesCodes = $attributeCodes;
     return $attributeCodes;
 }