getTable('sales/order_status'); $statusStateTable = $installer->getTable('sales/order_status_state'); $statusLabelTable = $installer->getTable('sales/order_status_label'); $installer->run(" CREATE TABLE `{$statusTable}` ( `status` varchar(32) NOT NULL, `label` varchar(128) NOT NULL, PRIMARY KEY (`status`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 "); $statuses = Mage::getConfig()->getNode('global/sales/order/statuses')->asArray(); $data = array(); foreach ($statuses as $code => $info) { $data[] = array( 'status' => $code, 'label' => $info['label'] ); } $installer->getConnection()->insertArray($statusTable, array('status', 'label'), $data); $installer->run(" CREATE TABLE `{$statusStateTable}` ( `status` varchar(32) NOT NULL, `state` varchar(32) NOT NULL, `is_default` tinyint(1) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (`status`,`state`), CONSTRAINT `FK_SALES_ORDER_STATUS_STATE_STATUS` FOREIGN KEY (`status`) REFERENCES `{$statusTable}` (`status`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 "); $states = Mage::getConfig()->getNode('global/sales/order/states')->asArray(); $data = array(); foreach ($states as $code => $info) { if (isset($info['statuses'])) { foreach ($info['statuses'] as $status => $statusInfo) { $data[] = array( 'status' => $status, 'state' => $code, 'is_default'=> is_array($statusInfo) && isset($statusInfo['@']['default']) ? 1 : 0 ); } } } $installer->getConnection()->insertArray( $statusStateTable, array('status', 'state', 'is_default'), $data ); $installer->run(" CREATE TABLE `{$statusLabelTable}` ( `status` varchar(32) NOT NULL, `store_id` smallint(5) unsigned NOT NULL, `label` varchar(128) NOT NULL, PRIMARY KEY (`status`,`store_id`), KEY `FK_SALES_ORDER_STATUS_LABEL_STORE` (`store_id`), CONSTRAINT `FK_SALES_ORDER_STATUS_LABEL_STATUS` FOREIGN KEY (`status`) REFERENCES `{$statusTable}` (`status`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `FK_SALES_ORDER_STATUS_LABEL_STORE` FOREIGN KEY (`store_id`) REFERENCES `{$installer->getTable('core/store')}` (`store_id`)ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ");