Check if attribute handle exist?

Permalink
I just wonder is there any api method to check if attribute handle exist or not?
i tried $page->getAttribute(), but the problem with this is that in case of being a boolean (like exclude_nav) it return false too.
and i suppose when use setAttribute() method, it should return false or something, in case that attribute handle does not exist, but it return Fatal Error.

shahroq
 
goutnet replied on at Permalink Best Answer Reply
you want to try this :

$ak = CollectionAttributeKey::getByHandle('my_attribute_handle');
if ( is_null($ak) || !is_object($ak) || !intval($ak->getAttributeKeyID()) ) echo "No attributeĀ !!"