Get all attribute options

To get all attribute options from a Magento dropdown attribute (select field) you can use the following snippet:

That gives you an array like that:

This can be used as source for a system config field for example. See my blogpost about Category dropdown element. To get a specific value by given label, you can […]

Load product attributes more performant

Recently I had performance issues when importing several ten tausend products. The problem was, that I always used the “normal” product entity model to load attribute values. The following snippet shows, how to load product attributes directly instead. Therefore I use the product resource singleton.

Get product attribute ID in Magento

This is how to get product EAV attribute ID without querying the database directly: