0
votes

I have successfully created a new customer attribute using the following files:

config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <LReward_CustomerAddCustomAttr>
            <version>0.1.1</version>
        </LReward_CustomerAddCustomAttr>
    </modules>
    <global>        
        <resources>
            <CustomerAddCustomAttr_setup>
                <setup>
                    <module>LReward_CustomerAddCustomAttr</module>
                    <class>LReward_CustomerAddCustomAttr_Model_Resource_Eav_Mysql4_Setup</class>
                </setup>
                <connection>
                    <use>core_setup</use>
                </connection>
            </CustomerAddCustomAttr_setup>
            <CustomerAddCustomAttr_write>
                <connection>
                    <use>core_write</use>
                </connection>
            </CustomerAddCustomAttr_write>
            <CustomerAddCustomAttr_read>
                <connection>
                    <use>core_read</use>
                </connection>
            </CustomerAddCustomAttr_read>
        </resources>        
    </global>
</config>

mysql4-install-0.1.0.php

<?php
$installer = $this;
$installer->startSetup();

$setup = Mage::getModel('customer/entity_setup', 'core_setup');

$setup->addAttribute('customer', 'reward_points', array(
    'type' => 'varchar',
    'input' => 'text',
    'label' => 'Reward points',
    'global' => 1,
    'visible' => 0,
    'required' => 0,
    'user_defined' => 0,
    'default' => '0',
    'visible_on_front' => 0,
    'source' =>   NULL,
));

$installer->endSetup();

Setup.php

<?php
class LReward_CustomerAddCustomAttr_Model_Resource_Eav_Mysql4_Setup extends Mage_Eav_Model_Entity_Setup {    
}

This creates a new customer attribute called "reward_points".

I now want to add another, but I cannot seem to do it. I figured that creating a new module with the same content but with new addAttribute values would work but it hasn't.

How do I add another new customer attribute?

1

1 Answers

0
votes
  1. Add upgrade-0.1.0-0.1.1.php
  2. Edit the content {your install code}
  3. edit version in config,xml, if required