Magneto 1 - Programmatically remove Customer Attribute

In Magento customer attributes is based on EAV structure (Entity Attribute Value) in some cases we need to add the customers custom attributes also want to remove those  to remove the attributes the code is as below

<?php
error_reporting(E_ALL | E_STRICT);
$mageFilename = 'app/Mage.php';
require_once $mageFilename;
Mage::setIsDeveloperMode(true);
umask(0);
Mage::app();

$setup = new Mage_Eav_Model_Entity_Setup('core_setup');

try {
    $custAttr = 'user_name';  // here enter your attribute name which you want to remove
    $setup->removeAttribute('customer', $custAttr);
    echo $custAttr." attribute is removed";
} catch (Mage_Core_Exception $e) {
    $this->_fault('data_invalid', $e->getMessage());
}

?>


Rakesh Singh Uniyal

I’m Rakesh Singh Uniyal (MCA) and I write to help people work on programming and technology. The tips, tutorials and information provided in this blog has helped many people to solve their programming and web development related issues.
I work as a Freelance PHP/Magento/Wordpress Developer.

No comments:

Post a Comment