Nav-Appaiya
9/6/2016 - 8:55 AM

Magento 2 get all attributes from the default products attribute set (id: 4)

Magento 2 get all attributes from the default products attribute set (id: 4)

<?php

    /** @var  $coll \Magento\Eav\Model\ResourceModel\Entity\Attribute\Collection */
    $coll = $this->_objectManager->create(\Magento\Eav\Model\ResourceModel\Entity\Attribute\Collection::class);
    // add filter by entity type to get product attributes only
    // '4' is the default type ID for 'catalog_product' entity - see 'eav_entity_type' table)
    // or skip the next line to get all attributes for all types of entities
    $coll->addFieldToFilter(\Magento\Eav\Model\Entity\Attribute\Set::KEY_ENTITY_TYPE_ID, 4);
    $attrAll = $coll->load()->getItems();