I want to retrieve all product attributes those are available, then convert it to name & value for my select options field. In Magento 1 I can achieve it like this:
public function getMagentoAttributes()
{
$values[] = array(
'value' => '',
'label' => 'Pick Product Attribute'
);
$categories = Mage::getResourceModel('catalog/product_attribute_collection')->getItems();
foreach ($categories as $category) {
if ($category->getFrontendLabel() != '') {
$label = $category->getFrontendLabel();
} else {
$label = $category->getAttributecode();
}
$values[] = array(
'value' => $category->getAttributecode(),
'label' => $label
);
}
return $values;
}
Is there a way in magento 2 to do the same thing?