Skip to content

Instantly share code, notes, and snippets.

@xus
Last active August 29, 2015 14:19
Show Gist options
  • Save xus/3b1cb813a4035384c20b to your computer and use it in GitHub Desktop.
Save xus/3b1cb813a4035384c20b to your computer and use it in GitHub Desktop.
Magneto - Programmatically remove Customer Attribute via file php in the root directory
<!-- PUT THIS CODE IN ONE PHP FILE IN THE ROOT DIRECTORY -->
<?php
error_reporting(E_ALL | E_STRICT);
include 'app/Mage.php';
Mage::app();
Mage::setIsDeveloperMode(true);
umask(0);
$attributeCode = "barrio"; //Put here your attribute code
// get all attribute
$attribute = Mage::getSingleton("eav/config")->getAttribute("customer_address", $attributeCode);
// get TypeId for that kind of attribute
$entityTypeId = Mage::getModel('eav/entity')->setType('customer_address')->getTypeId();
try {
$setup = Mage::getModel('customer/entity_setup', 'core_setup');
$setup->removeAttribute($entityTypeId, $attributeCode);
echo "Deleted!";
}
catch (Mage_Core_Exception $e) {
print_r($e->getMessage());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment