1
votes

I have created a custom attribute for customer in Magento.

I have accidentally set wrong type for my attribute.

Now I want to either modify this attribute or delete this one and then create new attribute.

Can any one tell me whether I can delete or modify custom attribute in magneto or not?

Thanks in advance.

1

1 Answers

11
votes

You can create an upgrade script in one of your modules with this content:

$this->updateAttribute('customer', 'attribute_code_here', 'type', 'varchar'); //or any other type

Basically you can change any attribute from customers, categories & products like this;

$entityType = 'customer';//or catalog_category or catalog_product
$attributeCode = 'attribute_code_here';
$changeWhat = 'field_name_here';
$changeInto = 'new value here';
$this->updateAttribute($entityType, $attributeCode, $changeWhat, $changeInto);

To remove an attribute run this:

$this->removeAttribute('customer', 'attribute_code_here');

It follows the same rules as above.