Skip to content

Commit e1e2afe

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-61560' into NORD-BUGFIXES-PR
2 parents 8545fd8 + 414c50c commit e1e2afe

File tree

3 files changed

+108
-12
lines changed

3 files changed

+108
-12
lines changed

app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/AbstractModifierTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ protected function setUp()
5656
$this->productMock = $this->getMockBuilder(ProductInterface::class)
5757
->setMethods([
5858
'getId',
59+
'getTypeId',
5960
'getStoreId',
6061
'getResource',
6162
'getData',

app/code/Magento/ConfigurableProduct/Test/Unit/Ui/DataProvider/Product/Form/Modifier/ConfigurablePriceTest.php

Lines changed: 97 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,106 @@ class ConfigurablePriceTest extends AbstractModifierTest
1515
*/
1616
protected function createModel()
1717
{
18-
return $this->objectManager->getObject(ConfigurablePriceModifier::class);
18+
return $this->objectManager->getObject(ConfigurablePriceModifier::class, ['locator' => $this->locatorMock]);
1919
}
2020

21-
public function testModifyMeta()
21+
/**
22+
* @param array $metaInput
23+
* @param array $metaOutput
24+
* @dataProvider metaDataProvider
25+
*/
26+
public function testModifyMeta($metaInput, $metaOutput)
2227
{
23-
$meta = ['initial' => 'meta'];
28+
$this->productMock->expects($this->any())
29+
->method('getTypeId')
30+
->willReturn(\Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE);
31+
32+
$metaResult = $this->getModel()->modifyMeta($metaInput);
33+
$this->assertEquals($metaResult, $metaOutput);
34+
}
2435

25-
$this->assertArrayHasKey('initial', $this->getModel()->modifyMeta($meta));
36+
/**
37+
* @return array
38+
*/
39+
public function metaDataProvider()
40+
{
41+
return [
42+
[
43+
'metaInput' => [
44+
'pruduct-details' => [
45+
'children' => [
46+
'container_price' => [
47+
'children' => [
48+
'advanced_pricing_button' => [
49+
'arguments' => []
50+
]
51+
]
52+
]
53+
]
54+
]
55+
],
56+
'metaOutput' => [
57+
'pruduct-details' => [
58+
'children' => [
59+
'container_price' => [
60+
'children' => [
61+
'advanced_pricing_button' => [
62+
'arguments' => [
63+
'data' => [
64+
'config' => [
65+
'visible' => 0,
66+
'disabled' => 1,
67+
'componentType' => 'container'
68+
],
69+
],
70+
],
71+
],
72+
'price' => [
73+
'arguments' => [
74+
'data' => [
75+
'config' => [
76+
'component' =>
77+
'Magento_ConfigurableProduct/js/components/price-configurable'
78+
],
79+
],
80+
],
81+
],
82+
],
83+
],
84+
],
85+
]
86+
]
87+
], [
88+
'metaInput' => [
89+
'pruduct-details' => [
90+
'children' => [
91+
'container_price' => [
92+
'children' => []
93+
]
94+
]
95+
]
96+
],
97+
'metaOutput' => [
98+
'pruduct-details' => [
99+
'children' => [
100+
'container_price' => [
101+
'children' => [
102+
'price' => [
103+
'arguments' => [
104+
'data' => [
105+
'config' => [
106+
'component' =>
107+
'Magento_ConfigurableProduct/js/components/price-configurable'
108+
]
109+
]
110+
]
111+
]
112+
]
113+
]
114+
]
115+
]
116+
]
117+
]
118+
];
26119
}
27120
}

app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/ConfigurablePrice.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,10 @@ public function modifyData(array $data)
4949
*/
5050
public function modifyMeta(array $meta)
5151
{
52-
if ($groupCode = $this->getGroupCodeByField($meta, ProductAttributeInterface::CODE_PRICE)
53-
?: $this->getGroupCodeByField($meta, self::CODE_GROUP_PRICE)
54-
) {
52+
$groupCode = $this->getGroupCodeByField($meta, ProductAttributeInterface::CODE_PRICE)
53+
?: $this->getGroupCodeByField($meta, self::CODE_GROUP_PRICE);
54+
55+
if ($groupCode && !empty($meta[$groupCode]['children'][self::CODE_GROUP_PRICE])) {
5556
if (!empty($meta[$groupCode]['children'][self::CODE_GROUP_PRICE])) {
5657
$meta[$groupCode]['children'][self::CODE_GROUP_PRICE] = array_replace_recursive(
5758
$meta[$groupCode]['children'][self::CODE_GROUP_PRICE],
@@ -71,7 +72,9 @@ public function modifyMeta(array $meta)
7172
]
7273
);
7374
}
74-
if (!empty($meta[$groupCode]['children'][self::CODE_GROUP_PRICE])) {
75+
if (
76+
!empty($meta[$groupCode]['children'][self::CODE_GROUP_PRICE]['children'][self::$advancedPricingButton])
77+
) {
7578
$productTypeId = $this->locator->getProduct()->getTypeId();
7679
$visibilityConfig = ($productTypeId === ConfigurableType::TYPE_CODE)
7780
? ['visible' => 0, 'disabled' => 1]
@@ -81,17 +84,16 @@ public function modifyMeta(array $meta)
8184
. ConfigurablePanel::CONFIGURABLE_MATRIX . ':isEmpty',
8285
]
8386
];
87+
$config = $visibilityConfig;
88+
$config['componentType'] = 'container';
8489
$meta[$groupCode]['children'][self::CODE_GROUP_PRICE] = array_replace_recursive(
8590
$meta[$groupCode]['children'][self::CODE_GROUP_PRICE],
8691
[
8792
'children' => [
8893
self::$advancedPricingButton => [
8994
'arguments' => [
9095
'data' => [
91-
'config' => [
92-
'componentType' => 'container',
93-
$visibilityConfig
94-
],
96+
'config' => $config,
9597
],
9698
],
9799
],

0 commit comments

Comments
 (0)