Skip to content

Commit 861e8e3

Browse files
Merge pull request #156 from mateus007/correios_tab
Install script for version 4.7.0
2 parents 8805110 + 7d72c7f commit 861e8e3

1 file changed

Lines changed: 141 additions & 0 deletions

File tree

  • app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
<?php
2+
3+
/**
4+
* This source file is subject to the MIT License.
5+
* It is also available through http://opensource.org/licenses/MIT
6+
*
7+
* @category PedroTeixeira
8+
* @package PedroTeixeira_Correios
9+
* @author Pedro Teixeira <hello@pedroteixeira.io>
10+
* @copyright 2015 Pedro Teixeira (http://pedroteixeira.io)
11+
* @license http://opensource.org/licenses/MIT MIT
12+
* @link https://github.com/pedro-teixeira/correios
13+
*/
14+
15+
/** @var $installer Mage_Core_Model_Resource_Setup */
16+
$installer = $this;
17+
$installer->startSetup();
18+
19+
$status = Mage::getModel('sales/order_status');
20+
$status->setStatus(PedroTeixeira_Correios_Model_Sro::ORDER_SHIPPED_STATUS)
21+
->setLabel('Pedido em Transporte')
22+
->assignState(Mage_Sales_Model_Order::STATE_COMPLETE)
23+
->save();
24+
25+
$status = Mage::getModel('sales/order_status');
26+
$status->setStatus(PedroTeixeira_Correios_Model_Sro::ORDER_WARNED_STATUS)
27+
->setLabel('Dificuldade de Entrega')
28+
->assignState(Mage_Sales_Model_Order::STATE_COMPLETE)
29+
->save();
30+
31+
/* @var $installer Mage_Catalog_Model_Resource_Eav_Mysql4_Setup */
32+
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
33+
34+
// Add volume to prduct attribute set
35+
$codigo = 'volume_comprimento';
36+
$config = array(
37+
'position' => 1,
38+
'required' => 0,
39+
'label' => 'Comprimento (cm)',
40+
'type' => 'int',
41+
'input' => 'text',
42+
'apply_to' => 'simple,bundle,grouped,configurable',
43+
'note' => 'Comprimento da embalagem do produto (Para cálculo dos Correios)'
44+
);
45+
46+
$setup->addAttribute('catalog_product', $codigo, $config);
47+
48+
// Add volume to prduct attribute set
49+
$codigo = 'volume_altura';
50+
$config = array(
51+
'position' => 1,
52+
'required' => 0,
53+
'label' => 'Altura (cm)',
54+
'type' => 'int',
55+
'input' => 'text',
56+
'apply_to' => 'simple,bundle,grouped,configurable',
57+
'note' => 'Altura da embalagem do produto (Para cálculo dos Correios)'
58+
);
59+
60+
$setup->addAttribute('catalog_product', $codigo, $config);
61+
62+
// Add volume to prduct attribute set
63+
$codigo = 'volume_largura';
64+
$config = array(
65+
'position' => 1,
66+
'required' => 0,
67+
'label' => 'Largura (cm)',
68+
'type' => 'int',
69+
'input' => 'text',
70+
'apply_to' => 'simple,bundle,grouped,configurable',
71+
'note' => 'Largura da embalagem do produto (Para cálculo dos Correios)'
72+
);
73+
74+
$setup->addAttribute('catalog_product', $codigo, $config);
75+
76+
$codigo = 'postmethods';
77+
$config = array(
78+
'position' => 1,
79+
'required' => 0,
80+
'label' => 'Serviços de Entrega',
81+
'type' => 'text',
82+
'input' => 'multiselect',
83+
'source' => 'pedroteixeira_correios/source_postMethods',
84+
'backend' => 'eav/entity_attribute_backend_array',
85+
'apply_to' => 'simple,bundle,grouped,configurable',
86+
'note' => 'Selecione os serviços apropriados para o produto.'
87+
);
88+
89+
$setup->addAttribute('catalog_product', $codigo, $config);
90+
91+
$codigo = 'fit_size';
92+
$config = array(
93+
'position' => 1,
94+
'required' => 0,
95+
'label' => 'Diferença do Encaixe (cm)',
96+
'type' => 'varchar',
97+
'input' => 'text',
98+
'apply_to' => 'simple,bundle,grouped,configurable',
99+
'note' => 'Exemplo: Se 1 item mede 10cm de altura, e 2 itens encaixados medem 11cm. A diferença é de 1cm.'
100+
);
101+
102+
$setup->addAttribute('catalog_product', $codigo, $config);
103+
104+
$codigo = 'posting_days';
105+
$config = array(
106+
'position' => 1,
107+
'required' => 0,
108+
'label' => 'Prazo de Postagem',
109+
'type' => 'int',
110+
'input' => 'text',
111+
'apply_to' => 'simple,bundle,grouped,configurable',
112+
'note' => 'O prazo total é o Prazo dos Correios acrescido do maior Prazo de Postagem dos produtos no carrinho.'
113+
);
114+
115+
$setup->addAttribute('catalog_product', $codigo, $config);
116+
117+
// Add Correios Tab
118+
$setIds = $setup->getAllAttributeSetIds('catalog_product');
119+
120+
$attributes = array(
121+
'volume_comprimento',
122+
'volume_altura',
123+
'volume_largura',
124+
'postmethods',
125+
'fit_size',
126+
'posting_days'
127+
);
128+
129+
foreach ( $setIds as $setId ) {
130+
131+
$setup->addAttributeGroup('catalog_product', $setId, 'Correios', 2);
132+
$groupId = $setup->getAttributeGroupId('catalog_product', $setId, 'Correios');
133+
134+
foreach ( $attributes as $attribute ) {
135+
$attributeId = $setup->getAttributeId('catalog_product', $attribute);
136+
$setup->addAttributeToGroup('catalog_product', $setId, $groupId, $attributeId);
137+
}
138+
139+
}
140+
141+
$installer->endSetup();

0 commit comments

Comments
 (0)