Magento EAV Attribute – Best Way to Check if Exists

attributeseavmagento-1.9

Who would know how to check if an attribute exists in magento before adding options to it?

Thanks a lot!

Best Answer

You should be able to do something like:

$entity = 'catalog_product';
$code = 'status';
$attr = Mage::getResourceModel('catalog/eav_attribute')
    ->loadByCode($entity,$code);

if ($attr->getId()) {
    // atttribute exists
}