0
votes

Okay so I am trying to add a field to the registration with my module. Obviously I have to add an attribute. So my "install script" is really just an upgrade to the customer entity. However, the module is enabled and yet when I refresh the front end it will not run my install script. I have put a die at the front to see if its even hitting it and its not.

I have checked about 7 other stack overflow questions and each of the errors was pretty blatant. Things like the config not matching the folder it was in. Using customer_setup as the name. Errors in the setup file. Over and over i've looked at my code and i KNOW im missing something small. Some typo somewhere.....but ive wasted too much time now, so I hand it off to you great people.

Config.xml

<config>
    <modules>
        <BlizzardLabs_Customer>
            <version>0.1.0</version>
        </BlizzardLabs_Customer>
    </modules>
    <global>
        <fieldsets>
            <customer_account>
                <flavour>
                  <create>1</create>
                  <update>1</update>
                </flavour>
            </customer_account>
        </fieldsets>
        <resources>
            <blizzardlabs_customer_setup>
                <setup>
                    <module>BlizzardLabs_Customer</module>
                    <class>BlizzardLabs_Customer_Model_Entity_Setup</class>
                </setup>
            </blizzardlabs_customer_setup>
        </resources>
    </global>
</config>

BlizzardLabs/Customer/Model/Entity/Setup.php

class BlizzardLabs_Customer_Model_Entity_Setup extends Mage_Customer_Model_Entity_Setup {

  public function getDefaultEntities() {
    $entities = parent::getDefaultEntities();

    // Add flavour to customer attributes
    $entities['customer']['attributes']['flavour'] = array(
        'label' => 'Ice Cream Flavour',
        'visible' => true,
        'required' => true,
    );

    return $entities;
  }

}

BlizzardLabs/Customer/sql/blizzardlabs_customer_setup/mysql4-install-0.1.0.php

Mage::log('Installing BlizzardLabs_Customer');

$installer = $this;
$installer->startSetup();
$installer->addAttribute('customer', 'flavour', array(
    'label' => 'Ice Cream Flavour',
    'type' => 'varchar',
    'input' => 'text',
    'visible' => true,
    'required' => true,
    'position' => 1,
));

$attrs = array('flavour');

foreach ($attrs as $item) {
  $attr = Mage::getSingleton('eav/config')->getAttribute('customer', $item);
  $attr->setData('used_in_forms', array('adminhtml_customer','customer_account_edit','customer_account_create'))->save();
}

$installer->endSetup();

echo "information added to database";
2
FYI, Magento now has its own StackExchange site: magento.stackexchange.comJohn Conde
thanks for the info....do you think i should move it there instead?Bill Garrison
I would guess you'd get a better response there.John Conde
ill keep it up for now....ill put it up there as well. I will just refrain from putting future magento questions here. ThanksBill Garrison

2 Answers

1
votes

So I figured it out. I am not sure if this is a version thing, but for thoroughness I am using magento 1.13.

Here is my issue:

<blizzardlabs_customer_setup>
</blizzardlabs_customer_setup>

Needed to be:

  <blizzardlabscustomer_setup>  
  </blizzardlabscustomer_setup>

I of course had to edit my folder to match this. So the new path is /BlizzardLabs/Customer/sql/blizzardlabscustomer_setup/<file_name>.

Also, for posterity sake, using "customer_setup" would not work because this would clash with the Magento base class and not run the install script.

I am not sure if this is a magento version issue or something old but you can't have any underscores before _setup. Thanks!

0
votes
BlizzardLabs/Customer/sql/mysql4-install-0.1.0.php

Shouldn't this be (In every module I've written at-least)

BlizzardLabs/Customer/sql/customer_setup/mysql4-install-0.1.0.php

or maybe (Above is likely to conflict with mage_customer anyway)

BlizzardLabs/Customer/sql/blizzardlabs_customer_setup/mysql4-install-0.1.0.php