$installer->getConnection()->commit();
/**
 * Insert NF-e tables 
 */
$installer->run("\r\n CREATE TABLE {$installer->getTable('nfe_certificado')} (\r\n  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,\r\n  `certificado` TEXT,\r\n  `created_at` TIMESTAMP NULL DEFAULT NULL,\r\n  PRIMARY KEY (`id`)\r\n) ENGINE=INNODB DEFAULT CHARSET=utf8 COMMENT='NFE Certificado';\r\n        \r\nCREATE TABLE {$installer->getTable('nfe_sales_order')} (\r\n  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,\r\n  `order_id` INT(8) UNSIGNED NOT NULL,\r\n  PRIMARY KEY (`id`),\r\n  KEY `order_id` (`order_id`),\r\n  CONSTRAINT `nfe_sales_order_ibfk_1` FOREIGN KEY (`order_id`) REFERENCES `sales_flat_order` (`entity_id`)\r\n) ENGINE=INNODB DEFAULT CHARSET=utf8 COMMENT='NFE Sales Order';\r\n\r\n\r\nCREATE TABLE {$installer->getTable('nfe_sales_order_nf')} (\r\n  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,\r\n  `nf_order_id` INT(10) UNSIGNED NOT NULL,\r\n  `shipment_id` INT(10) UNSIGNED DEFAULT NULL,\r\n  `status` VARCHAR(16) DEFAULT NULL,\r\n  `created_at` TIMESTAMP NULL DEFAULT NULL,\r\n  `executed_at` TIMESTAMP NULL DEFAULT NULL,\r\n  `finished_at` TIMESTAMP NULL DEFAULT NULL,\r\n  PRIMARY KEY (`id`),\r\n  KEY `nf_order_id` (`nf_order_id`),\r\n  KEY `nfe_sales_order_nf_ibfk_2` (`shipment_id`),\r\n  CONSTRAINT `nfe_sales_order_nf_ibfk_1` FOREIGN KEY (`nf_order_id`) REFERENCES `nfe_sales_order` (`id`),\r\n  CONSTRAINT `nfe_sales_order_nf_ibfk_2` FOREIGN KEY (`shipment_id`) REFERENCES `sales_flat_shipment` (`entity_id`)\r\n) ENGINE=INNODB DEFAULT CHARSET=utf8 COMMENT='NFE Sales Order NF';\r\n\r\nCREATE TABLE {$installer->getTable('nfe_sales_order_nf_request')} (\r\n  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,\r\n  `nfe_nf_id` INT(10) UNSIGNED NOT NULL,\r\n  `request` TEXT,\r\n  `messages` TEXT,\r\n  `status` VARCHAR(16) DEFAULT NULL,\r\n  `created_at` TIMESTAMP NULL DEFAULT NULL,\r\n  `executed_at` TIMESTAMP NULL DEFAULT NULL,\r\n  `finished_at` TIMESTAMP NULL DEFAULT NULL,\r\n  PRIMARY KEY (`id`),\r\n  KEY `nfe_nf_id` (`nfe_nf_id`),\r\n  CONSTRAINT `nfe_sales_order_request_ibfk_1` FOREIGN KEY (`nfe_nf_id`) REFERENCES `nfe_sales_order_nf` (`id`)\r\n) ENGINE=INNODB DEFAULT CHARSET=utf8 COMMENT='NFE Order Requests';\r\n\r\nINSERT sales_order_status (`status`, `label` ) VALUES ('complete_nf', 'Completo NFe emitida');\r\nINSERT sales_order_status (`status`, `label` ) VALUES ('error_nf', 'Processando NFe');\r\nINSERT sales_order_status (`status`, `label` ) VALUES ('pending_nf', 'Entrega Parcial');\r\n\r\nINSERT sales_order_status_label (`status`, `store_id`, `label` ) VALUES ('complete_nf', '1','Completo NFe emitida');\r\nINSERT sales_order_status_label (`status`, `store_id`, `label` ) VALUES ('pending_nf', '1', 'Entrega Parcial');\r\nINSERT sales_order_status_label (`status`, `store_id`, `label` ) VALUES ('error_nf', '1','Processando NFe');\r\n\r\nINSERT sales_order_status_state (`status`, `state`, `is_default` ) VALUES ('pending_nf', 'complete','0');\r\nINSERT sales_order_status_state (`status`, `state`, `is_default` ) VALUES ('complete_nf', 'complete','0');\r\nINSERT sales_order_status_state (`status`, `state`, `is_default` ) VALUES ('error_nf', 'complete','0');\r\n");
$installer->getConnection()->commit();
/**
 * Install NF-e attributes
 */
$installer = new Mage_Eav_Model_Entity_Setup('eav_setup');
$installer->addAttributeGroup('eav/attribute_group', 4, 'NF-e', 3);
$attributeGroupId = $installer->getAttributeGroup('eav/attribute_group', 4, 'NF-e', 'attribute_group_id');
$installer = new Mage_Catalog_Model_Resource_Eav_Mysql4_Setup('catalog_setup');
$entityTypeId = $installer->getEntityTypeId('catalog_product');
$attributeSetId = $installer->getDefaultAttributeSetId($entityTypeId);
$installer->addAttribute('catalog_product', 'nfe_ncm', array('type' => 'text', 'label' => 'NCM', 'input' => 'text', 'source' => '', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'required' => true, 'default' => ''));
$installer->addAttribute('catalog_product', 'nfe_orig', array('type' => 'int', 'label' => 'Origem da Mercadoria', 'input' => 'select', 'source' => 'easynfe_nfe/source_config_origem', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'required' => true, 'default' => ''));
$installer->addAttribute('catalog_product', 'nfe_ucom', array('type' => 'text', 'label' => 'Unidade Comercial', 'input' => 'text', 'source' => '', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'required' => true, 'default' => ''));
$installer->addAttributeToGroup($entityTypeId, $attributeSetId, $attributeGroupId, 'nfe_ncm', '1');
$installer->addAttributeToGroup($entityTypeId, $attributeSetId, $attributeGroupId, 'nfe_orig', '2');
$installer->addAttributeToGroup($entityTypeId, $attributeSetId, $attributeGroupId, 'nfe_ucom', '3');
$installer = new Mage_Sales_Model_Mysql4_Setup('sales_setup');
$installer->addAttribute('order_item', 'nfe_ncm', array('type' => 'text'));
$installer->addAttribute('quote_item', 'nfe_ncm', array('type' => 'text'));
$installer->addAttribute('shipment_item', 'nfe_ncm', array('type' => 'text'));
$installer->addAttribute('order_item', 'nfe_ucom', array('type' => 'text'));
$installer->addAttribute('quote_item', 'nfe_ucom', array('type' => 'text'));
$installer->addAttribute('shipment_item', 'nfe_ucom', array('type' => 'text'));
$installer->addAttribute('order_item', 'nfe_orig', array('type' => 'int'));
$installer->addAttribute('quote_item', 'nfe_orig', array('type' => 'int'));
$installer->addAttribute('shipment_item', 'nfe_orig', array('type' => 'int'));
Beispiel #2
0
 /**
  * Update associations between attributes, attribute groups and attribute sets
  *
  * @param array $data
  *
  * @return void
  */
 protected function _updateAttributeAssociations(array $data)
 {
     foreach ($data as $attribute) {
         $this->_setup->addAttributeToGroup($this->_catalogProductEntityTypeId, $attribute['attribute_set_id'], $attribute['attribute_group_id'], $attribute['attribute_id'], $attribute['sort_order']);
     }
 }