I have an old module and I need to update it so it will work with a newer Magento version. Basically the module adds some customer fields.

So there a config.xml like this:



Notice there is no resources setup config defined but stilll there is a Entity/Setup.php

class DWI_Customer_Model_Entity_Setup extends Mage_Eav_Model_Entity_Setup
    public function getDefaultEntities()
        return array(
            'customer' => array(
                'entity_model'          =>'customer/customer',
                'table'                 => 'customer/entity',
                'increment_model'       => 'eav/entity_increment_numeric',
                'increment_per_store'   => false,
                'additional_attribute_table' => 'customer/eav_attribute',
                'entity_attribute_collection' => 'customer/eav_attribute',
                'attributes' => array(
            'membernumber' => array(
            'label'     => 'Member No',
            'visible'   => true,
                        'sort_order'    => 65,

With newer version those fields are not visible (but added to eav_attribute) and I need to add an upgrade script like this:

$config->getAttribute('customer', 'membernumber' )
    ->setData( 'used_in_forms', array( 'adminhtml_customer' ) )

I did the with other modules and it worked fine. Problem here is I don't have sql/customer_setup/mysql4.... here. Also it looks like the module does not show up in core_resource or I am not sure how it would be named. customer_setup feels right but that is already been used by Mage/Customer.

Question is: How do I add an upgrade script for this module?

  • Name your resource node dwi_customer_setup. and put the upgrade scripts in sql/dwi_customer_setup. – Marius Jan 13 '14 at 12:29
  • You put the resources tag inside the fieldsets. Move it one level higher – Marius Jan 13 '14 at 14:34
  • @Marius Thanks for you help. That worked! Can you post your comments as an answer so I can give you the bounty. Would be a waste otherwise ;) – PiTheNumber Jan 13 '14 at 14:53
  • Done. Yey.. for bounty points :) – Marius Jan 13 '14 at 15:03

You can create the install script using the resource name dwi_customer_setup. In this case the upgrade scripts go under inside the folder sql/dwi_customer_setup of your extension.
This way you avoid the collision with the customer_setup resource.

In config.xml add the tag and changed version to 1.0.2.:


create DWI\Customer\sql\dwi_customer_setup\upgrade-1.0.1-1.0.2.php with



Mage::getSingleton( 'eav/config' )
->getAttribute( 'customer', 'membernumber' )
->setData( 'used_in_forms', array( 'adminhtml_customer' ) )


And very important as always: Clear your cache!

  • I feel kind of dirty for this answer. I only provided some suggestions. @PiTheNumber did the coding. – Marius Jan 13 '14 at 15:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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