How to delete an eav product attribute programmatically
It is my view that this sort of thing should be done via set-up script or if that is not possible then via the admin section. I cannot think of a situation where you need to write a script for this, but maybe there is one.
For a set-up script it is incredibly simple:
$this->startSetup();
// Remove Product Attribute
$this->removeAttribute('catalog_product', 'product_attribute_code');
// Remove Customer Attribute
$this->removeAttribute('customer', 'customer_attribute_code');
$this->endSetup();
If you need something more complex like removing groups or attribute sets that can also be done via a script too.
You can try below code
Mage::getModel('catalog/product_attribute_set_api')->attributeRemove($attributeId, $attributeSetId);
It will remove attribute from attribute set only but I am not sure if it will also remove it permanently.
For removing an attribute permanently, you can try below.
Mage::getModel('catalog/product_attribute_api')->remove($attributeId);
Other method is :
First create a test.php in magento root directory
Place below code there
<?php
error_reporting(E_ALL | E_STRICT);
require_once './app/Mage.php';
umask(0);
Mage::app();
$attr = 'test_remove'; //attribute code to remove
$setup = Mage::getResourceModel('catalog/setup', 'core_setup');
try {
$setup->startSetup();
$setup->removeAttribute('catalog_product', $attr);
$setup->endSetup();
echo $attr . " attribute is removed";
} catch (Mage_Core_Exception $e) {
print_r($e->getMessage());
}