Check if attribute code exists - magento-create-setup.php #3

Closed
florinel-chis opened this Issue Aug 14, 2012 · 1 comment

2 participants

@florinel-chis

After loading the attribute by code, it would be nice to check if the attribute code exists so you get a nice error message instead of stack trace...

 $m = Mage::getModel('catalog/resource_eav_attribute')
    ->loadByCode('catalog_product',$code);

Maybe:

if(null===$m->getId()) {
        //attribute does not exist
        echo "//ERROR: Attribute code: *".$code."* does not exists\n";
        return false;
}
@astorm
Owner

Good idea. I just pushed a fix for this.

@astorm astorm closed this Aug 16, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment