Create a new table from magento module

前端 未结 1 1264
滥情空心
滥情空心 2021-01-15 13:31

I am trying to have an admin module I am working on create a new table in the database. What I have setup in

app/code/local/Foo/BAR/sql/mysql4-install-0.1.0.php

相关标签:
1条回答
  • 2021-01-15 14:02

    If a setup/upgrade script isn't running, here are some things to check:

    1. Is Magento loading your module? Go to System > Configuration > Advanced > Advanced and see if your module appears in the "Disable Module Output" list. If it doesn't, Magento isn't loading your module at all, and therefore won't run any setup scripts. As Cags noted in his comment, you'll need an xml file in app/etc/modules to tell Magento to load your module if you haven't already created one.

    2. Make sure your resources are declared in the correct place in the config.xml file. They should be inside the <global> tag (this appears to be correct in your case).

    3. Make sure your setup files are in the correct location. They should be in a sql/ folder inside your module. I think this is your problem, the setup file in this example should be app/code/local/Foo/BAR/sql/BAR_setup/mysql4-install-0.1.0.php

    4. Having checked all of the above, if you have an IDE set up for debugging (and if you're doing any serious Magento work, do yourself a favor and get one up), set a breakpoint in the setup file and make sure it's being hit.

    5. Check the core_resource table in the database for a BAR_setup entry. If it's there, Magento has run the setup script once and won't run it again. If you need to run your setup script again, delete this record. Likewise you can change the version numbers if you ever need to re-run upgrade scripts (but make sure you understand the consequences of running setup/upgrade scripts a second time if you do).

    If all else fails check out Alan Storm's guide to debugging Magento setup scripts.

    0 讨论(0)
提交回复
热议问题