sebb
sebb

Reputation: 1966

Magento add custom column to Order

I am trying to save google cookie for each single order in magento.

I would like to add new column, let's say "google_cookie" to my table. How can I achieve that ?

And which table should be updated ? Is it sales_flat_order ?

Upvotes: 0

Views: 739

Answers (1)

faizanbeg
faizanbeg

Reputation: 391

<?php

$installer = $this;
$connection = $installer->getConnection();
$installer->startSetup();

$tableSales = $this->getTable('sales_flat_order');

if ($connection->tableColumnExists($tableSales, 'google_cookie') === false) {
    $connection->addColumn(
        $tableSales,
        'google_cookie',
        'varchar(255) Default Null'
    );
}

$installer->endSetup(); 

add new column using this above script and save data as per your requirement

Upvotes: 1

Related Questions