0
votes

In magento i created a custom module and completed the template and controller part, but confused about handling the model and db part. From my custom module i want to alter the table sales_flat_order_item and add an additional field. Now i created a set up script like

$installer = $this;
$installer->startSetup();
$installer->run("
ALTER TABLE sales_flat_order_item ADD COLUMN new_field TEXT NULL;

ALTER TABLE sales_flat_invoice_item ADD COLUMN new_field TEXT NULL;

ALTER TABLE sales_flat_shipment_item ADD COLUMN new_field TEXT NULL;
");
$installer->endSetup(); 

in path app\code\local\Namespace\Module\sql\_setup\mysql4-install-0.1.0.php But the table is not seems to be altered what configuration can be done in the script or module files to add the additional field and processing data with the same like the other fields. any one help. Thanks.

2
What version of magento are you using?Marty Wallace

2 Answers

1
votes

what is your config.xml configuration looks like?

under <global></global> tag you need to add:

<resources>
    <sql_setup>
        <setup>
            <module>Namespace_Module</module>
        </setup>
    </sql_setup>
</resources>
0
votes

try to put something like this

 $installer->run("
ALTER TABLE {$this->getTable('sales_flat_shipment_item')} ADD `new_field` TEXT NULL ;
");