I am thinking to update is_required data to "1" for existing "Region" attribute code.

select * From eav_attribute where attribute_id = '28'

However, I am wondering what is the practice here. Is it simply creating SQL statement and update that specific record in setup script fine? Or perhaps there may be a better way.

  • Which region attribute? for order or address? Commented Jan 24, 2014 at 10:43
  • for order and address =)
    – Leongelis
    Commented Jan 27, 2014 at 3:24
  • ok I have already added code in below answer :) Commented Jan 28, 2014 at 5:53

6 Answers 6


Create sql script to update region attribute

/*** Update customer address attributes*/
$installer->updateAttribute('customer_address', 'region', 'is_required', true); 

/*** Update order address attributes*/
$installer->updateAttribute('order_address', 'region', 'is_required', true);  

I hope above code will help

  • Can you please explain it in deep with example.
    – Ami Kamboj
    Commented Jun 20, 2014 at 10:13

I am writing this updates is simply sharing my research and hope could help someone out there.


                     Create a Switchable Installer Script 
                     This class is incredibly handy in case you need different setup classes 

Custom Setup Class: Package_Module_Model_Resource_Setup

class Package_Module_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup
    public function getCatalogResourceSetup()
        return new Mage_Catalog_Model_Resource_Setup('module_setup');
    public function getCustomerResourceSetup()
        return new Mage_Customer_Model_Resource_Setup('module_setup');
    public function getCustomerEntitySetup() 
        return new Mage_Customer_Model_Entity_Setup('module_setup');

Upgrade Script: mysql4-upgrade-0.0.1-0.0.2.php

/* @var $installer Package_Module_Model_Resource_Setup */
$installer = $this->getCustomerEntitySetup();

/*** Update customer address attributes*/
$installer->updateAttribute('customer_address', 'region', 'is_required', 1);


Hereby a great article that shared about 'Switchable Installer Script'. Source link: inchoo.net


Create sql update script and run updateAttribute function.

$installer = $this;
$installer->updateAttribute('entity_type', 'your_attribute_id', 'required', 1);

With this function you can update any attribute's property.


I was trying some scripts found, but the attribute still was required. The correct parameter is 'is_required' and not 'required'. $installer->updateAttribute('entity_type', 'your_attribute_id', 'is_required', 1);


Below code will update attribute using sql script

$installer = $this;
$this->updateAttribute('customer_address', 'region', 'is_required' ,1); 

you can find definition of updateAttribute() function in file app\code\core\Mage\Eav\Model\Entity\setup.php

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.