I've deleted a custom attribute on Customer > Customer Attributes > Manage Customer Attributes but I need it back.

Is it possible to recover it? The custom attribute are still on database?

  • How you deleted it ?
    – PЯINCƎ
    Mar 1, 2017 at 19:50
  • I've choose it on Manage Customer Attributes page and clicked on delete attribute Mar 1, 2017 at 19:59
  • I have a backup .sql from yesterday with these informations. But I don't know how to change only one column Mar 1, 2017 at 20:05
  • Look my answer below, you can also make a full restoration database with your backup.
    – PЯINCƎ
    Mar 1, 2017 at 20:20

1 Answer 1


If you deleted it like this, is that you deleted it also from the database, you have more than to recreate it again. if you don't know how, use this code below.

To add a custom attribute to customer:


$installer = $this;


$setup = new Mage_Eav_Model_Entity_Setup('core_setup');

$entityTypeId     = $setup->getEntityTypeId('customer');
$attributeSetId   = $setup->getDefaultAttributeSetId($entityTypeId);
$attributeGroupId = $setup->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);

$installer->addAttribute("customer", "customattribute",  array(
    "type"     => "varchar",
    "backend"  => "",
    "label"    => "Custom Attribute",
    "input"    => "text",
    "source"   => "",
    "visible"  => true,
    "required" => false,
    "default" => "",
    "frontend" => "",
    "unique"     => false,
    "note"       => "Custom Attribute"


        $attribute   = Mage::getSingleton("eav/config")->getAttribute("customer", "customattribute");

    '999'  //sort_order


        $attribute->setData("used_in_forms", $used_in_forms)
                ->setData("is_used_for_customer_segment", true)
                ->setData("is_system", 0)
                ->setData("is_user_defined", 1)
                ->setData("is_visible", 1)
                ->setData("sort_order", 100)



 <?xml version="1.0"?>




  <?xml version="1.0"?>

To retrieve it use:

$customer = Mage::getModel('customer/customer')->load($custid);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.