Last active
August 29, 2015 14:19
-
-
Save xus/3b1cb813a4035384c20b to your computer and use it in GitHub Desktop.
Magneto - Programmatically remove Customer Attribute via file php in the root directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- 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