Pregunta

Estoy tratando de crear un módulo simple para agregar comentarios de los clientes al finalizar la compra, sé que hay algunos regalos en el mercado que ya hacen esto, pero necesito extender aún más la funcionalidad, por lo que decidí hacerlo desde cero.

El problema es que ni siquiera puedo hacer que mi script de instalación se ejecute y crear las tablas necesarias. ¡He estado revisando el código durante horas pero no puedo hacer que funcione!

Cualquier ayuda sería muy bienvenida ...

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/Namespace_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();

No tengo idea de lo que está mal en mi script de instalación o mi config.xml. ¿Cuál sería la razón principal para que esto no ejecute y cree las tablas requeridas?

+-------------------------+------------+--------------+
| 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      |
¿Fue útil?

Solución

En tu tercera columna:

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

tú tienes type_int, parece que estás buscando un type_text Como lo define como un campo de comentarios con un límite de caracteres de 64k. Cuando esto falle, no instanciará la tabla correctamente o fallará.

Otros consejos

Descubrí que mi carpeta tenía namespace_checkoutcomments_setup Cuando necesitaba ser checkoutcomments_setup para que mi guión se ejecute.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a magento.stackexchange
scroll top