Skip to content

Commit be02d0d

Browse files
author
Ganin, Roman(rganin)
committed
Merge pull request #455 from magento-tango/MAGETWO-50596
[Tango] Bug fixes
2 parents 255ceb2 + 041b746 commit be02d0d

File tree

39 files changed

+1216
-759
lines changed

39 files changed

+1216
-759
lines changed

app/code/Magento/Bundle/Model/Product/Attribute/Source/Price/Type.php

Lines changed: 0 additions & 45 deletions
This file was deleted.

app/code/Magento/Bundle/Setup/UpgradeData.php

Lines changed: 119 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
*/
66
namespace Magento\Bundle\Setup;
77

8-
use Magento\Catalog\Model\Product;
8+
use Magento\Catalog\Api\Data\ProductAttributeInterface;
99
use Magento\Framework\Setup\ModuleContextInterface;
1010
use Magento\Framework\Setup\ModuleDataSetupInterface;
1111
use Magento\Framework\Setup\UpgradeDataInterface;
1212
use Magento\Eav\Setup\EavSetupFactory;
13+
use Magento\Eav\Setup\EavSetup;
1314

1415
class UpgradeData implements UpgradeDataInterface
1516
{
@@ -39,37 +40,125 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
3940
/** @var \Magento\Eav\Setup\EavSetup $eavSetup */
4041
$eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);
4142

42-
$eavSetup->updateAttribute(Product::ENTITY, 'price_type', 'frontend_input', 'boolean');
43-
$eavSetup->updateAttribute(
44-
Product::ENTITY,
45-
'price_type',
46-
'source_model',
47-
'Magento\Bundle\Model\Product\Attribute\Source\Price\Type'
48-
);
49-
$eavSetup->updateAttribute(Product::ENTITY, 'sku_type', 'frontend_input', 'boolean');
50-
$eavSetup->updateAttribute(
51-
Product::ENTITY,
52-
'sku_type',
53-
'source_model',
54-
'Magento\Bundle\Model\Product\Attribute\Source\Price\Type'
55-
);
56-
$eavSetup->updateAttribute(Product::ENTITY, 'weight_type', 'frontend_input', 'boolean');
57-
$eavSetup->updateAttribute(
58-
Product::ENTITY,
59-
'weight_type',
60-
'source_model',
61-
'Magento\Bundle\Model\Product\Attribute\Source\Price\Type'
62-
);
63-
$eavSetup->updateAttribute(Product::ENTITY, 'shipment_type', 'frontend_input', 'select');
64-
$eavSetup->updateAttribute(Product::ENTITY, 'shipment_type', 'frontend_label', __('Ship Bundle Items'), 1);
65-
$eavSetup->updateAttribute(
66-
Product::ENTITY,
67-
'shipment_type',
68-
'source_model',
69-
'Magento\Bundle\Model\Product\Attribute\Source\Shipment\Type'
70-
);
43+
$eavSetup->addAttributeGroup(ProductAttributeInterface::ENTITY_TYPE_CODE, 'Default', 'Bundle Items', 16);
44+
45+
$this->upgradePriceType($eavSetup);
46+
$this->upgradeSkuType($eavSetup);
47+
$this->upgradeWeightType($eavSetup);
48+
$this->upgradeShipmentType($eavSetup);
7149
}
7250

7351
$setup->endSetup();
7452
}
53+
54+
/**
55+
* Upgrade Dynamic Price attribute
56+
*
57+
* @param EavSetup $eavSetup
58+
* @return void
59+
*/
60+
private function upgradePriceType(EavSetup $eavSetup)
61+
{
62+
$eavSetup->updateAttribute(
63+
ProductAttributeInterface::ENTITY_TYPE_CODE,
64+
'price_type',
65+
'frontend_input',
66+
'boolean',
67+
31
68+
);
69+
$eavSetup->updateAttribute(
70+
ProductAttributeInterface::ENTITY_TYPE_CODE,
71+
'price_type',
72+
'frontend_label',
73+
'Dynamic Price'
74+
);
75+
$eavSetup->updateAttribute(ProductAttributeInterface::ENTITY_TYPE_CODE, 'price_type', 'default_value', 0);
76+
}
77+
78+
/**
79+
* Upgrade Dynamic Sku attribute
80+
*
81+
* @param EavSetup $eavSetup
82+
* @return void
83+
*/
84+
private function upgradeSkuType(EavSetup $eavSetup)
85+
{
86+
$eavSetup->updateAttribute(
87+
ProductAttributeInterface::ENTITY_TYPE_CODE,
88+
'sku_type',
89+
'frontend_input',
90+
'boolean',
91+
21
92+
);
93+
$eavSetup->updateAttribute(
94+
ProductAttributeInterface::ENTITY_TYPE_CODE,
95+
'sku_type',
96+
'frontend_label',
97+
'Dynamic SKU'
98+
);
99+
$eavSetup->updateAttribute(ProductAttributeInterface::ENTITY_TYPE_CODE, 'sku_type', 'default_value', 0);
100+
$eavSetup->updateAttribute(ProductAttributeInterface::ENTITY_TYPE_CODE, 'sku_type', 'is_visible', 1);
101+
}
102+
103+
/**
104+
* Upgrade Dynamic Weight attribute
105+
*
106+
* @param EavSetup $eavSetup
107+
* @return void
108+
*/
109+
private function upgradeWeightType(EavSetup $eavSetup)
110+
{
111+
$eavSetup->updateAttribute(
112+
ProductAttributeInterface::ENTITY_TYPE_CODE,
113+
'weight_type',
114+
'frontend_input',
115+
'boolean',
116+
71
117+
);
118+
$eavSetup->updateAttribute(
119+
ProductAttributeInterface::ENTITY_TYPE_CODE,
120+
'weight_type',
121+
'frontend_label',
122+
'Dynamic Weight'
123+
);
124+
$eavSetup->updateAttribute(ProductAttributeInterface::ENTITY_TYPE_CODE, 'weight_type', 'default_value', 0);
125+
$eavSetup->updateAttribute(ProductAttributeInterface::ENTITY_TYPE_CODE, 'weight_type', 'is_visible', 1);
126+
}
127+
128+
/**
129+
* Upgrade Ship Bundle Items attribute
130+
*
131+
* @param EavSetup $eavSetup
132+
* @return void
133+
*/
134+
private function upgradeShipmentType(EavSetup $eavSetup)
135+
{
136+
$eavSetup->addAttributeToGroup(
137+
ProductAttributeInterface::ENTITY_TYPE_CODE,
138+
'Default',
139+
'Bundle Items',
140+
'shipment_type',
141+
1
142+
);
143+
$eavSetup->updateAttribute(
144+
ProductAttributeInterface::ENTITY_TYPE_CODE,
145+
'shipment_type',
146+
'frontend_input',
147+
'select'
148+
);
149+
$eavSetup->updateAttribute(
150+
ProductAttributeInterface::ENTITY_TYPE_CODE,
151+
'shipment_type',
152+
'frontend_label',
153+
'Ship Bundle Items'
154+
);
155+
$eavSetup->updateAttribute(
156+
ProductAttributeInterface::ENTITY_TYPE_CODE,
157+
'shipment_type',
158+
'source_model',
159+
'Magento\Bundle\Model\Product\Attribute\Source\Shipment\Type'
160+
);
161+
$eavSetup->updateAttribute(ProductAttributeInterface::ENTITY_TYPE_CODE, 'shipment_type', 'default_value', 0);
162+
$eavSetup->updateAttribute(ProductAttributeInterface::ENTITY_TYPE_CODE, 'shipment_type', 'is_visible', 1);
163+
}
75164
}

app/code/Magento/Bundle/Test/Unit/Model/Product/Attribute/Source/Price/TypeTest.php

Lines changed: 0 additions & 52 deletions
This file was deleted.

app/code/Magento/Bundle/Test/Unit/Ui/DataProvider/Product/Form/Modifier/BundleSkuTest.php

Lines changed: 46 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,44 +6,71 @@
66
namespace Magento\Bundle\Test\Unit\Ui\DataProvider\Product\Form\Modifier;
77

88
use Magento\Bundle\Ui\DataProvider\Product\Form\Modifier\BundleSku;
9-
use Magento\Catalog\Api\Data\ProductAttributeInterface;
9+
use Magento\Framework\Stdlib\ArrayManager;
1010

11-
/**
12-
* Class BundleSkuTest
13-
*/
1411
class BundleSkuTest extends AbstractModifierTest
1512
{
1613
/**
1714
* @return BundleSku
1815
*/
1916
protected function createModel()
2017
{
21-
return $this->objectManager->getObject(BundleSku::class, [
22-
'arrayManager' => $this->arrayManagerMock,
23-
]);
18+
return $this->objectManager->getObject(
19+
BundleSku::class,
20+
['arrayManager' => $this->arrayManagerMock]
21+
);
2422
}
2523

26-
/**
27-
* @return void
28-
*/
2924
public function testModifyMeta()
3025
{
26+
$skuTypePath = 'bundle-items/children/' . BundleSku::CODE_SKU_TYPE;
27+
$skuTypeConfigPath = $skuTypePath . BundleSku::META_CONFIG_PATH;
3128
$sourceMeta = [
32-
'testGroup' => [
29+
'bundle-items' => [
3330
'children' => [
34-
ProductAttributeInterface::CODE_SKU => [
35-
'componentType' => 'testComponent',
36-
],
31+
BundleSku::CODE_SKU_TYPE => []
3732
]
33+
]
34+
];
35+
$skuTypeParams = [
36+
'valueMap' => [
37+
'false' => '1',
38+
'true' => '0'
3839
],
40+
'validation' => [
41+
'required-entry' => false
42+
]
3943
];
40-
$modifiedMeta = $this->getModel()->modifyMeta($sourceMeta);
41-
$this->assertArrayHasKey(BundleSku::CODE_SKU_TYPE, $modifiedMeta['testGroup']['children']);
44+
$skuTypeMeta = [
45+
'bundle-items' => [
46+
'children' => [
47+
BundleSku::CODE_SKU_TYPE => $skuTypeParams
48+
]
49+
]
50+
];
51+
52+
$this->arrayManagerMock->expects(static::any())
53+
->method('findPath')
54+
->willReturnMap(
55+
[
56+
[
57+
BundleSku::CODE_SKU_TYPE,
58+
$sourceMeta,
59+
null,
60+
'children',
61+
ArrayManager::DEFAULT_PATH_DELIMITER,
62+
$skuTypePath
63+
]
64+
]
65+
);
66+
$this->arrayManagerMock->expects($this->once())
67+
->method('merge')
68+
->with($skuTypeConfigPath, $sourceMeta, $skuTypeParams)
69+
->willReturn($skuTypeMeta);
70+
71+
$this->assertSame($skuTypeMeta, $this->getModel()->modifyMeta($sourceMeta));
4272
}
4373

44-
/**
45-
* @return void
46-
*/
4774
public function testModifyData()
4875
{
4976
$expectedData = [];

0 commit comments

Comments
 (0)