nano
nano

Reputation: 2521

Can't load new Order attribute in Magento

I've a module where I'm adding a new attribute to sales/order class.

ALTER TABLE `{$installer->getTable('sales/order')}` ADD `my_attribute` tinyint(2) DEFAULT '0' COMMENT 'BLA BLA';

Looking into the database I can see this new attribute in sales/order table.

But when I load an order in the payment process with:

$_order = new Mage_Sales_Model_Order();
$orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
$_order->loadByIncrementId($orderId);

this order is not loading the new attribute my_attribute. It looks my_attribute is created but Mage_Sales_Model_Order is not recognizing it.

How can I load the order with my new custom attribute?

Upvotes: 0

Views: 65

Answers (1)

Manashvi Birla
Manashvi Birla

Reputation: 2843

Try adding this to below file :

Namespace/Module/etc/config.php

<global>
   ….. 
    <fieldsets>
        <sales_convert_quote>                           
            <my_attribute><to_order>*</to_order></my_attribute>
        </sales_convert_quote>

        <sales_convert_order>                                              
            <my_attribute><to_quote>*</to_quote></my_attribute>
        </sales_convert_order>
    </fieldsets>
    …
</global>

Upvotes: 1

Related Questions