add multiple columns magento table scripts

This tutorial explains how to add multiple columns magento table scripts. The code below show to add multiple columns to existing custom table magento module.

Please also refer other magento tutorials and how to create custom tables magento installer script.

Existing Magento Table

add multiple columns magento table scripts

Upgrade magento table

add multiple columns magento table scripts

Click here to download the upgrade script and the config file.

<?php
$installer = $this;
$installer->startSetup();
 
$installer->getConnection()
    ->addColumn($installer->getTable('imagedetail'),'filters_workshop_colour', 
        array(
        'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
        'nullable' => true,
        'comment' => 'Filters Workshop Colour'
    ));
$installer->getConnection()
    ->addColumn($installer->getTable('imagedetail'),'splashbackcolor', 
        array(
        'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
        'nullable' => true,
        'comment' => 'Splash Back Color'
        ));
$installer->getConnection()
    ->addColumn($installer->getTable('imagedetail'),'cabinetcolor', 
        array(
        'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
        'nullable' => true,
        'comment' => 'Cabinet Color'
        ));
        

$installer->endSetup();
?>

Share this Tutorial