3

i followed this tutorial and got problems with the install script. I get the following error:

Can't retrieve entity config: practice_checkoutcomments/comments

here is the code:

app\etc\modules\Practice_CheckoutComments.xml

    <?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <Practice_CheckoutComments>
            <active>true</active>
            <codePool>local</codePool>
            <depends>
                <Mage_Sales />
                <Mage_CatalogInventory />
                <Mage_Checkout />
            </depends>
        </Practice_CheckoutComments>
    </modules>
</config>

app\code\local\Practice\CheckoutComments\etc\config.xml

   <?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <Practice_CheckoutComments>
            <version>0.0.1</version>
        </Practice_CheckoutComments>
    </modules>

    <global>
        <resources>
            <checkoutcomments_setup>
                <setup>
                    <module>Practice_CheckoutComments</module>
                </setup>
            </checkoutcomments_setup>
        </resources>
    </global>
</config>

app\code\local\Practice\CheckoutComments\sql\checkoutcomments_setup\install-0.0.1.php

   <?php
$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_TEXT, '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();
?>
5

Firstly you are missing the model, resource and collection for your extension and also you are missing the table definition in config.xml. You can define the model classes via config.xml as follows:

<models>
    <checkoutcomments>
        <class>Practice_CheckoutComments_Model</class>
        <resourceModel>checkoutcomments_resource</resourceModel>
    </checkoutcomments>
    <checkoutcomments_resource>
        <class>Practice_CheckoutComments_Model_Resource</class>
        <entities>
            <comments_table>
                <table>comments_table</table>
            </comments_table>
        </entites>
    </checkoutcomments_resource>
</models>

You then need to create your model, resource and collection in your extension. I would recommend Alan Storm's blog for a good basic insight into Magento's ORM

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.