书籍:"Getting Started with Magento Extension Development"、sql 迁移脚本未执行

Book: "Getting Started with Magento Extension Development", sql migration script not executed

我按照书中提到的相同步骤进行了操作,关键步骤是:

  1. <Module Directory>/etc/config.xml 创建资源设置配置如下:

    <?xml version="1.0"?>
    <config>
        <global>
            <modules>
                <Foggyline_HappyHour>
                    <version>1.0.0.0</version>
                </Foggyline_HappyHour>
            </modules>
    
            <!-- Some Other Configuration (Doesn't matter) -->
    
            <resources>
                <foggyline_happyhour_setup>
                    <setup>
                        <model>Foggyline_HappyHour</model>
                    </setup>
                </foggyline_happyhour_setup>
            </resources>
    
            <!-- Some Other Configuration (Doesn't matter) -->
    
        </global>
    </config>
    
  2. <Module Directory>/sql/foggyline_happyhour_setup/install-1.0.0.0.php 使用以下脚本创建迁移脚本:

    <?php
    // Just checking if the script is executed
    echo 'Thank you for your help :)';
    
  3. 加载任何页面并检查页面是否打印消息。

不,它没有打印任何东西。该脚本根本没有 运行。

我们该如何解决这个问题?

:( 显然书中有一个 错别字 ):

根据official docs,设置定义应该是<module>而不是<model>。因此:

<?xml version="1.0"?>
<config>
    <global>

        <!-- Some Other Configuration (Doesn't matter) -->

        <resources>
            <foggyline_happyhour_setup>
                <setup>
                    <module>Foggyline_HappyHour</module>
                </setup>
            </foggyline_happyhour_setup>
        </resources>

        <!-- Some Other Configuration (Doesn't matter) -->

    </global>
</config>

现在我可以看到执行的脚本了。 :)