attributeRepository = $attributeRepository; $this->metadataPool = $metadataPool; $this->searchCriteriaBuilder = $searchCriteriaBuilder; } /** * Get attributes list from attribute set * * @param string $entityType * @param int|null $attributeSetId * @return \Magento\Eav\Api\Data\AttributeInterface[] */ public function getAttributes($entityType, $attributeSetId = null) { $metadata = $this->metadataPool->getMetadata($entityType); if ($attributeSetId === null) { $criteria = $this->searchCriteriaBuilder->addFilter(self::ATTRIBUTE_SET_ID, null, 'neq')->create(); } else { $criteria = $this->searchCriteriaBuilder->addFilter(self::ATTRIBUTE_SET_ID, $attributeSetId)->create(); } $searchResult = $this->attributeRepository->getList( $metadata->getEavEntityType(), $criteria ); $attributes = $searchResult->getItems(); return $attributes; } }