title: Magento 2 : How to get product attributes collection in custom module block file whose status is visible =>yes?
body: <p>Here is my function for calling product attribute collection I have already get product attributes for the product's which are enabled but I am having issue in filtering them according to their own visibility i.e I want only those product attributes collection whose status is set visible from admin....</p>
  
  <pre><code>class ProductList extends \Magento\Framework\View\Element\Template
  {
  protected $_attributeFactory;
  
  public function __construct(
           \Magento\Catalog\Model\ResourceModel\Eav\Attribute $attributeFactory
  
           ){
      parent::__construct($context);
      $this-&gt;_attributeFactory = $attributeFactory;
      }
  
  public function getallattributes()
  {
      $arr = [];
      $attributeInfo = $this-&gt;_attributeFactory-&gt;getCollection()-&gt;addFieldToFilter(\Magento\Eav\Model\Entity\Attribute\Set::KEY_ENTITY_TYPE_ID, 4);
  
     foreach($attributeInfo as $attributes)
     {
          $attributeId = $attributes-&gt;getAttributeId();
          // You can get all fields of attribute here
  
           $arr[$attributes-&gt;getAttributeId()] = $attributes-&gt;getFrontendLabel();
  
  
     }
     return $arr;
   }                                                                    } 
  </code></pre>