Ejemplo n.º 1
0
 /**
  * @param string $entityType
  * @return \Magento\Eav\Api\Data\AttributeInterface[]
  * @throws \Exception
  */
 protected function getAttributes($entityType)
 {
     $attributes = $this->attributeCache->getAttributes($entityType);
     if ($attributes) {
         return $attributes;
     }
     $metadata = $this->metadataPool->getMetadata($entityType);
     $searchResult = $this->attributeRepository->getList($metadata->getEavEntityType(), $this->searchCriteriaBuilder->create());
     $attributes = $searchResult->getItems();
     $this->attributeCache->saveAttributes($entityType, $attributes);
     return $attributes;
 }
Ejemplo n.º 2
0
 /**
  * Retrieve configuration for all attributes
  *
  * @param AbstractEntity $resource
  * @param DataObject|null $object
  * @return AbstractEntity
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function loadAllAttributes(AbstractEntity $resource, DataObject $object = null)
 {
     $suffix = $this->getLoadAllAttributesCacheSuffix($object);
     $typeCode = $resource->getEntityType()->getEntityTypeCode();
     $attributes = $this->cache->getAttributes($typeCode, $suffix);
     if ($attributes) {
         foreach ($attributes as $attribute) {
             $resource->addAttribute($attribute);
         }
         return $resource;
     }
     $attributes = $this->checkAndInitAttributes($resource, $object);
     $this->cache->saveAttributes($typeCode, $attributes, $suffix);
     return $resource;
 }