1

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";

Update: I apologize for the typo. the script IS in blizzardlabs_customer_setup

code_resource table:

+-------------------------------------+---------+
| code                                | version |
+-------------------------------------+---------+
| adminnotification_setup             | 1.0.0   |
| admin_setup                         | 0.7.1   |
| amazonpayments_setup                | 0.1.2   |
| api_setup                           | 0.8.1   |
| backup_setup                        | 0.7.0   |
| bundle_setup                        | 0.1.8   |
| catalogindex_setup                  | 0.7.10  |
| cataloginventory_setup              | 0.7.5   |
| catalogrule_setup                   | 0.7.7   |
| catalogsearch_setup                 | 0.7.6   |
| catalog_setup                       | 0.7.69  |
| checkout_setup                      | 0.9.3   |
| chronopay_setup                     | 0.1.0   |
| cms_setup                           | 0.7.8   |
| compiler_setup                      | 0.1.0   |
| contacts_setup                      | 0.8.0   |
| core_setup                          | 0.8.13  |
| cron_setup                          | 0.7.1   |
| customer_setup                      | 0.8.11  |
| cybermut_setup                      | 0.1.0   |
| cybersource_setup                   | 0.7.0   |
| dataflow_setup                      | 0.7.4   |
| directory_setup                     | 0.8.5   |
| downloadable_setup                  | 0.1.15  |
| eav_setup                           | 0.7.13  |
| enterprise_admingws_setup           | 0.0.1   |
| enterprise_catalogevent_setup       | 0.0.4   |
| enterprise_catalogpermissions_setup | 0.0.6   |
| enterprise_customerbalance_setup    | 0.0.10  |
| enterprise_enterprise_setup         | 0.0.1   |
| enterprise_giftcardaccount_setup    | 0.0.12  |
| enterprise_giftcard_setup           | 0.0.8   |
| enterprise_invitation_setup         | 0.0.3   |
| enterprise_logging_setup            | 0.1.8   |
| enterprise_pci_setup                | 0.0.3   |
| enterprise_staging_setup            | 0.1.10  |
| enterprise_websiterestriction_setup | 0.0.1   |
| eway_setup                          | 0.1.0   |
| flo2cash_setup                      | 0.1.1   |
| giftmessage_setup                   | 0.7.2   |
| googleanalytics_setup               | 0.1.0   |
| googlebase_setup                    | 0.1.1   |
| googlecheckout_setup                | 0.7.3   |
| googleoptimizer_setup               | 0.1.2   |
| ideal_setup                         | 0.1.0   |
| log_setup                           | 0.7.6   |
| newsletter_setup                    | 0.8.0   |
| oscommerce_setup                    | 0.8.10  |
| paybox_setup                        | 0.1.3   |
| paygate_setup                       | 0.7.0   |
| payment_setup                       | 0.7.0   |
| paypaluk_setup                      | 0.7.0   |
| paypal_setup                        | 0.7.2   |
| poll_setup                          | 0.7.2   |
| productalert_setup                  | 0.7.2   |
| protx_setup                         | 0.1.0   |
| rating_setup                        | 0.7.2   |
| reports_setup                       | 0.7.7   |
| review_setup                        | 0.7.4   |
| salesrule_setup                     | 0.7.7   |
| sales_setup                         | 0.9.38  |
| sendfriend_setup                    | 0.7.2   |
| shipping_setup                      | 0.7.0   |
| sitemap_setup                       | 0.7.2   |
| strikeiron_setup                    | 0.9.1   |
| tag_setup                           | 0.7.2   |
| tax_setup                           | 0.7.8   |
| usa_setup                           | 0.7.0   |
| weee_setup                          | 0.13    |
| wishlist_setup                      | 0.7.4   |
+-------------------------------------+---------+
3
  • Can you paste the contents of core_resource table in mysql?
    – philwinkle
    Commented Apr 23, 2013 at 14:13
  • Contents added. Let me know if you need anything else Commented Apr 23, 2013 at 14:21
  • 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 am not sure if this is a magento version issue or something old but you can't have any underscores before _setup. Thanks! Commented Apr 23, 2013 at 14:35

2 Answers 2

3

I think you need to add the mysql4-install-0.1.0.php inside a folder called blizzardlabs_customer_setup. Just like the name of your xml tag inside the <resources> tag. So the path should be BlizzardLabs/Customer/sql/blizzardlabs_customer_setup/mysql4-install-0.1.0.php. Before trying it again with the modified path make sure you delete the record from the table core_resource with the code blizzardlabs_customer_setup and clear the cache.
Off topic. If you work with Magento EE 1.12 you can lose the mysql4 in the install script name. You can make it install-0.1.0.php. But it's not that important. It works both ways.

[EDIT]
I've tested tried to run your script. I've created the files as you described. The only thing I added was the module declaration file: app/etc/modules/BlizzardLabs_Customer.xml with this content.

<?xml version="1.0"?>
<config>
    <modules>
        <BlizzardLabs_Customer>
            <active>true</active>
            <codePool>local</codePool>
            <depends>
                <Mage_Customer />
            </depends>
        </BlizzardLabs_Customer>
    </modules>
</config>

And everything worked perfectly. Make sure you cleared the cache. Make sure that the local modules are not disabled (in app/etc/local.xml this tag is set to false <disable_local_modules>false</disable_local_modules>). This is all I can think about.

7
  • sorry for the typo.....it IS in there. :) Commented Apr 23, 2013 at 14:19
  • Also I tried with and without mysql4 (as I am trying to stay database agnostic) and neither worked. Commented Apr 23, 2013 at 14:28
  • I've edited my response. I've added new info.
    – Marius
    Commented Apr 23, 2013 at 14:46
  • So, does adding this <depends> config make it so you can have multiple underscores in the setup name? (see my answer in my comments)... if so, why? Is this a bug? Intentional? If you can explain how this fixes the thing I found in my answer I will mark up your answer and choose it as the answer for the question. Commented Apr 23, 2013 at 18:01
  • adding the <depends> tag in the declaration file tells magento that your module cannot work without the Mage_Customer module and it is loaded after the Mage_Customer module. I don't think it has something to do with multiple underscores un the setup file. but then again I never tested on EE 1.13. Only 1.12.
    – Marius
    Commented Apr 23, 2013 at 18:06
-2

Thought I should do the right thing and post this. On looking in the "core_resource" table in the database I can already see a customer_setup entry that is from the magento core.

My guess is that this is why you can't use blizzardlabs_customer_setup not anything to do with 2 underscores. So one of the checks after running the install if you can't see it in "core_resource" table should be to ensure you haven't used anything that could contravene with already existing entries, e.g. anything_customer_setup_g

4
  • Your idea is good, but This is wrong. As long the name is unique over all setups, it should run. So customer_setup won't run but *_customer_setup has to. Commented Dec 23, 2013 at 7:36
  • Well I've used 2 underscores so as Marius says I'm pretty sure it's nothing to do with that. Before downvoting you should probably suggest reasoning of your own otherwise we promote a culture that decentivises suggestions_g Commented Jan 6, 2014 at 15:40
  • Upvote good questions/answers, downvote wrong answers. And your answers is wrong. But when you edit your answer, I'll remove the vote. Commented Jan 6, 2014 at 15:51
  • whatever you think man_ Commented Jan 7, 2014 at 22:22

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.