public function emitirAction()
 {
     $orders = $_POST['order_ids'];
     foreach ($orders as $number) {
         $order = Mage::getModel('sales/order')->load($number);
         // Emissão automática de Nota Fiscal
         $notafiscal = new WebmaniaBR_NFe_Model_Observer();
         $response = $notafiscal->emitirNfe($order, null, null, true);
         $orderno = (int) $order->getIncrementId();
         if (isset($response->error)) {
             Mage::getSingleton('core/session')->addError("Nota Fiscal #" . $orderno . ': ' . $response->error);
             if ($response->log) {
                 foreach ($response->log as $erros) {
                     foreach ($erros as $erro) {
                         Mage::getSingleton('core/session')->addError("- " . $erro);
                     }
                 }
             }
         } else {
             $setup = new Mage_Sales_Model_Resource_Setup('core_setup');
             $attribute = array('type' => 'text', 'input' => 'text', 'label' => 'NFe emitidas', 'global' => 0, 'visible' => 1, 'required' => 0, 'user_defined' => 1, 'visible_on_front' => 0);
             $setup->addAttribute('order', 'all_nfe', $attribute);
             $setup->endSetup();
             $existing_nfe = unserialize(base64_decode($order->getData('all_nfe')));
             if (!$existing_nfe) {
                 $existing_nfe = array();
             }
             $nfe_info = array('status' => (string) $response->status, 'chave_acesso' => $response->chave, 'n_recibo' => (int) $response->recibo, 'n_nfe' => (int) $response->nfe, 'n_serie' => (int) $response->serie, 'url_xml' => (string) $response->xml, 'url_danfe' => (string) $response->danfe, 'data' => date('d/m/Y'));
             $existing_nfe[] = $nfe_info;
             $nfe_info_str = base64_encode(serialize($existing_nfe));
             $order->setData('all_nfe', $nfe_info_str);
             $order->save();
             Mage::getSingleton('core/session')->addSuccess("Nota Fiscal #" . $orderno . ': Emitida com sucesso.');
         }
     }
     session_write_close();
     $url = Mage::helper('adminhtml')->getUrl('adminhtml/sales_order/');
     $this->_redirectUrl($url);
 }
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category    Magentando
 * @package     Magentando_SplitDelivery
 * @copyright   Copyright (c) 2014 Magentando <http://www.magentando.com.br>
 * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 * @author      Leandro Rosa <*****@*****.**>
 *
 */
$installer = new Mage_Sales_Model_Resource_Setup('core_setup');
$entities = array('quote', 'quote_item', 'order', 'order_item');
$options = array('type' => Varien_Db_Ddl_Table::TYPE_TEXT, 'visible' => true, 'required' => false);
foreach ($entities as $entity) {
    $installer->addAttribute($entity, 'splitdelivery', $options);
}
$installer->endSetup();
        $allOrderGroups = $connection->fetchAll($select);
        if ($allOrderGroups) {
            $installer->run('LOCK TABLES ' . $connection->quoteIdentifier($installer->getTable('sales/order_grid'), true) . ' WRITE;');
            foreach ($allOrderGroups as $value) {
                $connection->update($installer->getTable('sales/order_grid'), array('order_group_id' => intval($value['order_group_id'])), 'entity_id = ' . intval($value['order_id']));
            }
            $installer->run('UNLOCK TABLES;');
            $installer->run('LOCK TABLES ' . $connection->quoteIdentifier($installer->getTable('sales/order'), true) . ' WRITE;');
            foreach ($allOrderGroups as $value) {
                $connection->update($installer->getTable('sales/order'), array('order_group_id' => intval($value['order_group_id'])), 'entity_id = ' . intval($value['order_id']));
            }
            $installer->run('UNLOCK TABLES;
                DROP TABLE IF EXISTS `' . $installer->getTable('mageworx_orderspro_order_item_group') . '`;
                ALTER TABLE `' . $installer->getTable('mageworx_orderspro_order_group') . '` CHANGE `order_group_id` `order_group_id` TINYINT UNSIGNED NOT NULL AUTO_INCREMENT;');
        }
    }
}
// 1.18.9 > 1.19.0
$pathLike = 'mageworx_sales/orderspro/%';
$configCollection = Mage::getModel('core/config_data')->getCollection();
$configCollection->getSelect()->where('path like ?', $pathLike);
foreach ($configCollection as $conf) {
    $path = $conf->getPath();
    $path = str_replace('orderspro', 'general', $path);
    $path = str_replace('mageworx_sales', 'mageworx_orderspro', $path);
    $conf->setPath($path)->save();
}
$salesInstaller = new Mage_Sales_Model_Resource_Setup('core_setup');
$salesInstaller->addAttribute('quote_item', 'orderspro_is_temporary', array('type' => 'int', 'nullable' => true, 'grid' => false));
$salesInstaller->endSetup();
$installer->endSetup();
<?php

$setup = new Mage_Sales_Model_Resource_Setup('core_setup');
if (!$this->getAttribute(Mage_Sales_Model_Order::ENTITY, 'vindi_subscription_id', 'attribute_id')) {
    $setup->addAttribute(Mage_Sales_Model_Order::ENTITY, 'vindi_subscription_id', ['type' => 'varchar', 'input' => 'text', 'backend' => '', 'frontend' => '', 'label' => 'Id da Assinatura Vindi', 'class' => '', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, 'visible' => false, 'required' => false, 'user_defined' => false, 'default' => '', 'searchable' => false, 'filterable' => false, 'comparable' => false, 'visible_on_front' => false, 'unique' => false]);
}
if (!$this->getAttribute(Mage_Sales_Model_Order::ENTITY, 'vindi_subscription_period', 'attribute_id')) {
    $setup->addAttribute(Mage_Sales_Model_Order::ENTITY, 'vindi_subscription_period', ['type' => 'varchar', 'input' => 'text', 'backend' => '', 'frontend' => '', 'label' => 'Período da Assinatura Vindi', 'class' => '', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, 'visible' => false, 'required' => false, 'user_defined' => false, 'default' => '', 'searchable' => false, 'filterable' => false, 'comparable' => false, 'visible_on_front' => false, 'unique' => false]);
}
$setup->endSetup();