我正在尝试创建一个简单的模块以在结帐时添加客户评论,我知道市场上已经有一些免费赠品已经这样做了,但是我需要进一步扩展功能,因此决定从头开始浏览它。

问题是我什至无法让我的安装脚本运行并创建必要的表。我已经修改了代码了几个小时,但无法正常工作!!!

任何帮助将受到极大的欢迎...

config.xml

    <?xml version="1.0"?>
<config>
    <modules>
        <Namespace_CheckoutComments>
            <version>0.1.0</version>
        </Namespace_CheckoutComments>
    </modules>
    <global>
        <resources>
            <checkoutcomments_setup>
                <setup>
                    <module>Namespace_CheckoutComments</module>
                </setup>
            </checkoutcomments_setup>
        </resources>

        <models>
            <checkoutcomments>
                <class>Namespace_CheckoutComments_Model</class>
                <resourceModel>checkoutcomments_resource</resourceModel>
            </checkoutcomments>

            <checkoutcomments_resource>
                <class>Namespace_CheckoutComments_Model_Resource</class>
                <entities>
                    <comments_table>
                        <table>checkout_comments</table>
                    </comments_table>
                </entities>
            </checkoutcomments_resource>
        </models>

    </global>
</config>

sql/nesspace_checkoutcomments_setup/install-0.1.0.php

<?php

/* @var $installer Mage_Core_Model_Resource_Setup */
$installer = $this;

$installer->startSetup();

$table = $installer->getConnection()->newTable($installer->getTable('checkoutcomments/comments_table'))
    ->addColumn('comment_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
        'identity' => true,
        'unsigned' => true,
        'nullable' => false,
        'primary'  => true,
    ),  'Comment ID')

    ->addColumn('order_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
        'unsigned' => true,
        'nullable' => false,
    ),  'Real Order ID')

    ->addColumn('comment', Varien_Db_Ddl_Table::TYPE_INTEGER, '64k', array(
    ), 'Comment')

    ->addForeignKey(
        $installer->getFkName(
        'checkoutcomments/comments_table',
        'order_id',
        'sales/order',
        'entity_id'
    ),
        'order_id', $installer->getTable('sales/order'), 'entity_id',
        Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
        ->setComment('Checkout Comments');

$installer->getConnection()->createTable($table);
$installer->endSetup();

我不知道我的安装脚本或config.xml有什么问题。不执行并创建所需表的主要原因是什么?

+-------------------------+------------+--------------+
| code                    | version    | data_version |
+-------------------------+------------+--------------+
| adminnotification_setup | 1.6.0.0    | 1.6.0.0      |
| admin_setup             | 1.6.1.1    | 1.6.1.1      |
| api2_setup              | 1.0.0.0    | 1.0.0.0      |
| api_setup               | 1.6.0.1    | 1.6.0.1      |
| backup_setup            | 1.6.0.0    | 1.6.0.0      |
| bundle_setup            | 1.6.0.0.1  | 1.6.0.0.1    |
| captcha_setup           | 1.7.0.0.0  | 1.7.0.0.0    |
| catalogindex_setup      | 1.6.0.0    | 1.6.0.0      |
| cataloginventory_setup  | 1.6.0.0.2  | 1.6.0.0.2    |
| catalogrule_setup       | 1.6.0.3    | 1.6.0.3      |
| catalogsearch_setup     | 1.6.0.0    | 1.6.0.0      |
| catalog_setup           | 1.6.0.0.18 | 1.6.0.0.18   |
| checkoutcomments_setup  | 0.0.1      | 0.0.1        |
| checkout_setup          | 1.6.0.0    | 1.6.0.0      |
有帮助吗?

解决方案

在您的第三列中:

addColumn(
    'comment',
    Varien_Db_Ddl_Table::TYPE_INTEGER,
    '64k',
    array(),
    'Comment'
)

你有 type_int, ,看起来您正在寻找 type_text 当您将其定义为具有64K字符限制的注释字段时。如果失败,它将无法正确实例化或失败。

其他提示

发现我的文件夹有 namespace_checkoutcomments_setup 当需要 checkoutcomments_setup 我的脚本运行。

许可以下: CC-BY-SA归因
scroll top