Magento 2 get all product attributes without product id

protected $_attributeFactory;

 public function __construct(
    ....
    \Magento\Catalog\Model\ResourceModel\Eav\Attribute $attributeFactory,
    ....
) {
    ....
    $this->_attributeFactory = $attributeFactory;
    ....
}

public function <func_name>()
{
    $attributeInfo = $this->_attributeFactory->getCollection();

   foreach($attributeInfo as $attributes)
   {
        $attributeId = $attributes->getAttributeId();
        // You can get all fields of attribute here
   }
}

Here you can have whole collection of attributes, you can filter it as per your need.


Another idea is that we should try with Service Contracts Layer.

Use Magento\Eav\Api\AttributeRepositoryInterface to get the eav attribute.

I have an answer already here: https://magento.stackexchange.com/a/161426/33057

For example:

    $searchCriteria = $this->searchCriteriaBuilder->create();
    $attributeRepository = $this->attributeRepository->getList(
        'catalog_product',
        $searchCriteria
    );

    foreach ($attributeRepository->getItems() as $items) {
        $items->getAttributeCode();
        $items->getFrontendLabel();
    }

NOTE: For the entity type code in getList method, we can find in the eav_entity_type table.