书:" Magento扩展开发入门",sql迁移脚本未执行

时间:2015-05-21 10:17:45

标签: magento

我遵循了本书中提到的相同步骤,关键步骤是:

  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. 加载任何页面并检查页面是否打印消息。

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

    我们如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

:(显然书中有错误):

根据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>

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