I would like to add two custom field for order process.

My config file:


Below is MySQl:

Location: app\code\local\Ucs\CatalogOrder\sql\sales_custom_attribute\mysql4-install-1.0.0.php

$installer = $this;

$this->addAttribute('quote_item', 'card_wallet_amount', array(
        'type' => 'varchar',
        'input' => 'text',
        'label' => 'Card handling Charges',
        'global' => 1,
        'visible' => 1,
        'required' => 0,
        'user_defined' => 1,
        'visible_on_front' => 0
$this->addAttribute('order_item', 'card_wallet_amount', array(
        'type' => 'varchar',
        'input' => 'text',
        'label' => 'Card handling Charges',
        'global' => 1,
        'visible' => 1,
        'required' => 0,
        'user_defined' => 1,
        'visible_on_front' => 0


After clearing cache I reload my page. When I check core_resource I can see the module sql record. But the fields haven't been added.


In older Magento quote and order are using EAV attributes but from Magento version 1.6 orders does not have attributes anymore.

So instead of attribute you will need to create fields in sales_flat_quote_item and sales_flat_order_item tables.

For that you will need to use alter table script in your sql setup file.

$installer->run("ALTER TABLE `{$installer->getTable('sales/quote_item')}` ADD `card_wallet_amount` varchar(255) DEFAULT NULL;");
$installer->run("ALTER TABLE `{$installer->getTable('sales/order_item')}` ADD `card_wallet_amount` varchar(255) DEFAULT NULL;");

And you will need to save your value in quote. In your module config.xml file you will need to convert your quote field to order. You can do like

| improve this answer | |
  • Thanks for your reply. I am clear till the $installer->run("ALTER TABLE ... part. Whats the second part? Should it be required? – Butterfly Oct 12 '15 at 6:27
  • 1
    yes, it is require. I think you are talking about xml part. once you save your value to sales_flat_quote_item table and place your order. system will automatically copy this field value from sales_flat_quote_item to sales_flat_order_item table. – Akhilesh Patel Oct 12 '15 at 7:30
  • Thanks mate. I will try it once and accept. +1 now. Thank you so much – Butterfly Oct 12 '15 at 10:36
  • But when I get order details using $order = Mage::getModel('sales/order')->load($orderId); these custom values are not getting displayed? – Butterfly Oct 12 '15 at 13:40
  • you will need to get order items from this order object. you can get it my $ordered_items = $order->getAllItems(); also make sure in your order item table your custom field value saved correctly after placing an order. – Akhilesh Patel Oct 12 '15 at 15:54

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.