eavConfig = $eavConfig; $this->attrFormCollectionFactory = $attrFormCollectionFactory; $this->storeManager = $storeManager; } /** * Get attribute model for a given entity type and code * * @param string $entityType * @param string $attributeCode * @return false|AbstractAttribute */ public function getAttribute($entityType, $attributeCode) { return $this->eavConfig->getAttribute($entityType, $attributeCode); } /** * Get all attribute codes for a given entity type and attribute set * * @param string $entityType * @param int $attributeSetId * @param string|null $storeId * @return array Attribute codes */ public function getAllAttributeCodes($entityType, $attributeSetId = 0, $storeId = null) { if (null === $storeId) { $storeId = $this->storeManager->getStore()->getId(); } $object = new \Magento\Framework\DataObject( [ 'store_id' => $storeId, 'attribute_set_id' => $attributeSetId, ] ); return $this->eavConfig->getEntityAttributeCodes($entityType, $object); } /** * Load collection with filters applied * * @param string $entityType * @param string $formCode * @return \Magento\Customer\Model\ResourceModel\Form\Attribute\Collection */ public function loadAttributesCollection($entityType, $formCode) { $attributesFormCollection = $this->attrFormCollectionFactory->create(); $attributesFormCollection->setStore($this->storeManager->getStore()) ->setEntityType($entityType) ->addFormCodeFilter($formCode) ->setSortOrder(); return $attributesFormCollection; } }