0

hi have to add a custom attribute to the Customer. so i've extended the core Customer module, these are files involved and directory tree:

//app/code/local/Nauba/etc/config.xml

<?xml version="1.0"?>
<config>
<modules>
    <Nauba_Customer>
        <version>0.0.1</version>
    </Nauba_Customer>
</modules>

<global>
    <models>
        <customer>
            <rewrite>
                <customer>Nauba_Customer_Model_Customer</customer>
            </rewrite>
        </customer>
    </models>     
</global>   
</config>


 // app/code/local/Nauba/Customer/Model/Customer.php

class Nauba_Customer_Model_Customer extends Mage_Customer_Model_Customer
{
    function _construct()
    {
        parent::__construct();
    }
}




// app/etc/modules/Nauba_Customer.xml

<?xml version="1.0"?>
<config>
<modules>
    <Nauba_Customer>
        <active>true</active>
        <codePool>local</codePool>
   </Nauba_Customer>
</modules>
</config>






//app/code/local/Nauba/Customer/sql/nauba_customer_setup/mysql4-upgrade-1.6.2.0.2-1.6.2.0.3.php

$installer = $this;
$installer->startSetup();
/**
 * Adding custom attributes to customer
 */

$installer->addAttribute('customer', 'elite_invitation', array(
    'label'             => 'ID prodotto invito Elite',
    'type'              => 'varchar',
    'visible'           => true,
    'visible_on_front'  => false,
    'required'          => false,
    'backend'           => '',
    'frontend'          => '',
    'input'             => 'text',
    'global'            => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE
));


$installer->endSetup();

Now the module is enabled and new custom model is used instead of core Mage_Customer, but sql upgrade is not executed. any idea of what is wrong?

thanx luke

3
  • how you can say new model is used instead of Mage_Customer? Commented Aug 8, 2012 at 8:46
  • @KalpeshMehta putting in a template Mage::log(var_export($customer, true)), and seeing that that the class is Nauba_Customer_Model_Customer Commented Aug 8, 2012 at 8:52
  • ok great. Now include resources node in config.xml as suggested by @Jerzy. Commented Aug 8, 2012 at 8:55

1 Answer 1

1

you must define "resources" in xml under global

    <resources>
      <nauba_customer_setup>
         <setup>
             <module>your module name</module>
         </setup>
      </nauba_customer_setup>
     </resources>
Sign up to request clarification or add additional context in comments.

1 Comment

thanx. now my setup is executed, but i can't see my attribute in backend's customer account information section. i'm looking on other upgrades of other modules which i have locally to find something useful, but i still not found anything...any help?

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.