Magento安装脚本从不运行


Magento Install script never runs

我正在尝试使用自定义模块创建一个自定义表。我一直在关注Alan Storm的文章来创建一个自定义表

这是我的文件夹结构

CM
 Tablecreation
 etc >> config.xml (has 1.6.0.0 as the version mentioned)
 Helper >> Data.php
 controllers >> IndexController.php
 Model
  Actualtable.php
  Mysql4
   Actualtable.php
  Resource
   Mysql4
     Setup.php
  sql
   tablecreation_setup
     install-1.6.0.0.php

这是我的config.xml文件。

  <?xml version="1.0" encoding="UTF-8"?>
  <config>
  <modules>
    <CM_Tablecreation>
        <version>1.6.0.0</version>
    </CM_Tablecreation>
</modules>
<frontend>
    <routers>
        <tablecreation>
            <use>standard</use>
            <args>
                <module>CM_Tablecreation</module>
                <frontName>tablecreation</frontName>
            </args>
        </tablecreation>
    </routers>
</frontend>    
<global>
    <models>
        <tablecreation>
            <class>CM_Tablecreation_Model</class>
            <resourceModel>tablecreation_mysql4</resourceModel>
        </tablecreation>
        <tablecreation_mysql4>
        <class>CM_Tablecreation_Model_Mysql4</class>     
        <entities>
            <actualtable>
                <table>actual_table</table>
            </actualtable>
        </entities>                    
    </tablecreation_mysql4>
    </models>
    <resources>
    <tablecreation_setup>
    <setup>
        <module>CM_Tablecreation</module>
        <class>CM_Tablecreation_Model_Resource_Mysql4_Setup</class>
    </setup>
    <connection>
        <use>core_setup</use>
    </connection>
    </tablecreation_setup>
    <tablecreation_write>
        <connection>
            <use>core_write</use>
        </connection>
    </tablecreation_write>
    <tablecreation_read>
        <connection>
            <use>core_read</use>
        </connection>
    </tablecreation_read>      
</resources>      
    <helpers>
            <tablecreation>
                <class>CM_Tablecreation_Helper</class>
            </tablecreation>
    </helpers>
</global>
</config>

这是我每次都会遇到的错误

  a:5:{i:0;s:69:"/home/dev/public_html/app/code///sql/tablecreation_setup not found";i:1;s:818:"#0 /home/dev/public_html/app/code/core/Mage/Core/Model/Resource/Setup.php(421): Mage_Core_Model_Resource_Setup->_modifyResourceDb('install', '', '1.6.0.0')

我试着在app/code/core/Mage/core/Resource/Setup.php中放入带有异常消息的try-catch进行调试,正如之前关于这个主题的一些类似问题中所建议的那样,但没有成功

我的模块甚至没有在core_resource表中列出。即使它是这样做的,表肯定永远不会被创建。

当它确实在core_resource表中列出时,我也遇到过这种情况,但如果我从表中删除我的模块的记录(再次运行安装脚本),然后尝试刷新我的网站的任何页面,我会在打开报告时再次出现错误。

基本上,我在网上关注的任何一篇文章,我都会陷入同样的错误。请帮我解释这个错误和它的原因。也许还有人能建议什么是解决方案来排序。

非常感谢。

我可以看到你发布的内容有几个问题:

  1. 你的安装脚本需要被称为mysql4-install-1.6.0.0.php。如果Magento因为名称不正确而找不到安装脚本,它将无法运行,所以我会将你的install-1.6.0.0.php重命名为mysql4-stall-1.6.0.0.php。

  2. 您需要在config.xml文件的全局部分中有一个resources标记,它看起来像这样:

    <resources>
        <tablecreation_setup>
            <setup>
                <module>CM_Tablecreation</module>
            </setup>
            <connection>
                <use>core_setup</use>
            </connection>
        </tablecreation_setup>
    </resources>
    
  3. 检查您的应用程序/etc/modules.CM_Tablecreation.xml文件。您发布的错误消息很有趣,因为它试图定位安装文件的路径中缺少代码池和模块名称。检查您的xml文件是否具有config>modules>YourModule_NameHere>codePool标记(注意,codePool带有大写P),该标记包含字符串"core"、"community"或"local",具体取决于模块所在的位置。

你可能会在我之前对类似问题的回答以及艾伦·斯托姆对这个问题的明确回答中找到一些帮助。

附言:您的扩展版本不需要与Magento本身的版本号相同。只要从任何让你高兴的版本号开始,并根据需要增加。