Skip to content

Commit 238dc26

Browse files
Merge branch 'MAGETWO-48913' of https://github.corp.magento.com/magento-tango/magento2ce into MAGETWO-48913
2 parents cfbf78f + 723b12e commit 238dc26

File tree

8 files changed

+111
-146
lines changed

8 files changed

+111
-146
lines changed

app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ protected function setProductLinks(\Magento\Catalog\Model\Product $product)
217217

218218
foreach ($linkTypes as $linkType => $readonly) {
219219
if (isset($links[$linkType]) && !$readonly) {
220-
foreach ($links[$linkType] as $linkData) {
220+
foreach ((array) $links[$linkType] as $linkData) {
221221
if (empty($linkData['id'])) {
222222
continue;
223223
}

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

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,43 +6,25 @@
66
namespace Magento\Catalog\Test\Unit\Ui\DataProvider\Product\Form\Modifier;
77

88
use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\ScheduleDesignUpdate;
9-
use Magento\Catalog\Ui\DataProvider\Grouper;
109

1110
/**
1211
* Class ScheduleDesignUpdateTest
1312
*/
1413
class ScheduleDesignUpdateTest extends AbstractModifierTest
1514
{
16-
/**
17-
* @var Grouper|\PHPUnit_Framework_MockObject_MockObject
18-
*/
19-
protected $grouper;
20-
21-
protected function setUp()
22-
{
23-
parent::setUp();
24-
$this->grouper = $this->getMockBuilder(Grouper::class)
25-
->disableOriginalConstructor()
26-
->getMock();
27-
}
28-
2915
/**
3016
* {@inheritdoc}
3117
*/
3218
protected function createModel()
3319
{
3420
return $this->objectManager->getObject(ScheduleDesignUpdate::class, [
35-
'grouper' => $this->grouper,
21+
'arrayManager' => $this->arrayManagerMock,
3622
]);
3723
}
3824

3925
public function testModifyMeta()
4026
{
41-
$this->grouper->expects($this->any())
42-
->method('getGroupCodeByField')
43-
->willReturn('test_group_code');
44-
45-
$this->assertNotEmpty($this->getModel()->modifyMeta([]));
27+
$this->assertSame([], $this->getModel()->modifyMeta([]));
4628
}
4729

4830
public function testModifyData()

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AdvancedPricing.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,7 @@ protected function specialPriceDataToInline()
525525
'label' => __('Special Price From'),
526526
'additionalClasses' => 'admin__control-grouped-date',
527527
'breakLine' => false,
528+
'component' => 'Magento_Ui/js/form/components/group',
528529
'scopeLabel' =>
529530
$this->arrayManager->get($pathFrom . '/arguments/data/config/scopeLabel', $this->meta),
530531
]

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/General.php

Lines changed: 46 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -299,55 +299,54 @@ protected function customizeWeightField(array $meta)
299299
*/
300300
protected function customizeNewDateRangeField(array $meta)
301301
{
302-
$mainElement = 'news_from_date';
303-
304-
$mainElementPath = $this->getElementArrayPath($meta, $mainElement);
305-
$meta = $this->grouper->groupMetaElements(
306-
$meta,
307-
[
308-
$mainElement => [
309-
'meta' => [
310-
'arguments' => [
311-
'data' => [
312-
'config' => [
313-
'label' => __('Set Product as New From'),
314-
'scopeLabel' => null,
315-
'additionalClasses' => 'admin__field-date'
316-
],
317-
],
318-
],
319-
]
320-
],
321-
'news_to_date' => [
322-
'meta' => [
323-
'arguments' => [
324-
'data' => [
325-
'config' => [
326-
'label' => __('To'),
327-
'scopeLabel' => null,
328-
'additionalClasses' => 'admin__field-date',
329-
],
330-
],
331-
]
332-
]
302+
$fromField = 'news_from_date';
303+
$toField = 'news_to_date';
304+
305+
$fromFieldPath = $this->getElementArrayPath($meta, $fromField);
306+
$toFieldPath = $this->getElementArrayPath($meta, $toField);
307+
308+
if ($fromFieldPath && $toFieldPath) {
309+
$fromContainerPath = $this->arrayManager->slicePath($fromFieldPath, 0, -2);
310+
$toContainerPath = $this->arrayManager->slicePath($toFieldPath, 0, -2);
311+
$scopeLabel = $this->arrayManager->get($fromFieldPath . self::META_CONFIG_PATH . '/scopeLabel', $meta);
312+
313+
$meta = $this->arrayManager->merge(
314+
$fromFieldPath . self::META_CONFIG_PATH,
315+
$meta,
316+
[
317+
'label' => __('Set Product as New From'),
318+
'scopeLabel' => null,
319+
'additionalClasses' => 'admin__field-date',
333320
]
334-
],
335-
[
336-
'targetCode' => 'news_date_range',
337-
'meta' => [
338-
'arguments' => [
339-
'data' => [
340-
'config' => [
341-
'label' => __('Set Product as New From'),
342-
'additionalClasses' => 'admin__control-grouped-date',
343-
'breakLine' => false,
344-
'scopeLabel' => $this->arrayManager->get($mainElementPath . '/scopeLabel', $meta),
345-
],
346-
],
347-
],
321+
);
322+
$meta = $this->arrayManager->merge(
323+
$toFieldPath . self::META_CONFIG_PATH,
324+
$meta,
325+
[
326+
'label' => __('To'),
327+
'scopeLabel' => null,
328+
'additionalClasses' => 'admin__field-date',
348329
]
349-
]
350-
);
330+
);
331+
$meta = $this->arrayManager->merge(
332+
$fromContainerPath . self::META_CONFIG_PATH,
333+
$meta,
334+
[
335+
'label' => __('Set Product as New From'),
336+
'additionalClasses' => 'admin__control-grouped-date',
337+
'breakLine' => false,
338+
'component' => 'Magento_Ui/js/form/components/group',
339+
'scopeLabel' => $scopeLabel,
340+
]
341+
);
342+
$meta = $this->arrayManager->set(
343+
$fromContainerPath . '/children/' . $toField,
344+
$meta,
345+
$this->arrayManager->get($toFieldPath, $meta)
346+
);
347+
348+
$meta = $this->arrayManager->remove($toContainerPath, $meta);
349+
}
351350

352351
return $meta;
353352
}

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/ScheduleDesignUpdate.php

Lines changed: 47 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66
namespace Magento\Catalog\Ui\DataProvider\Product\Form\Modifier;
77

8-
use Magento\Catalog\Ui\DataProvider\Grouper;
8+
use Magento\Framework\Stdlib\ArrayManager;
99

1010
/**
1111
* Class ScheduleDesignUpdateMetaProvider customizes Schedule Design Update panel
@@ -20,23 +20,24 @@ class ScheduleDesignUpdate extends AbstractModifier
2020
/**#@-*/
2121

2222
/**
23-
* @var Grouper
23+
* @var ArrayManager
2424
*/
25-
protected $grouper;
25+
protected $arrayManager;
2626

2727
/**
28-
* @param Grouper $grouper
28+
* @param ArrayManager $arrayManager
2929
*/
30-
public function __construct(Grouper $grouper)
30+
public function __construct(ArrayManager $arrayManager)
3131
{
32-
$this->grouper = $grouper;
32+
$this->arrayManager = $arrayManager;
3333
}
3434

3535
/**
3636
* {@inheritdoc}
3737
*/
3838
public function modifyMeta(array $meta)
3939
{
40+
//return $meta;
4041
return $this->customizeDateRangeField($meta);
4142
}
4243

@@ -63,58 +64,47 @@ protected function customizeDateRangeField(array $meta)
6364
return $meta;
6465
}
6566

66-
$groupCode = $this->getGroupCodeByField($meta, self::CODE_CUSTOM_DESIGN_FROM);
67-
$parentChildren = &$meta[$groupCode]['children'];
67+
$fromFieldPath = $this->getElementArrayPath($meta, self::CODE_CUSTOM_DESIGN_FROM);
68+
$toFieldPath = $this->getElementArrayPath($meta, self::CODE_CUSTOM_DESIGN_TO);
69+
$fromContainerPath = $this->arrayManager->slicePath($fromFieldPath, 0, -2);
70+
$toContainerPath = $this->arrayManager->slicePath($toFieldPath, 0, -2);
71+
$scopeLabel = $this->arrayManager->get($fromFieldPath . self::META_CONFIG_PATH . '/scopeLabel', $meta);
6872

69-
if (isset($parentChildren[self::CODE_CUSTOM_DESIGN_FROM])) {
70-
$parentChildrenConfig = $parentChildren[self::CODE_CUSTOM_DESIGN_FROM]['arguments']['data']['config'];
71-
$meta = $this->grouper->groupMetaElements(
72-
$meta,
73-
[
74-
self::CODE_CUSTOM_DESIGN_FROM => [
75-
'meta' => [
76-
'arguments' => [
77-
'data' => [
78-
'config' => [
79-
'label' => __('Schedule Update From'),
80-
'scopeLabel' => null,
81-
'additionalClasses' => 'admin__field-date'
82-
]
73+
$meta = $this->arrayManager->merge(
74+
$fromFieldPath . self::META_CONFIG_PATH,
75+
$meta,
76+
[
77+
'label' => __('Schedule Update From'),
78+
'scopeLabel' => null,
79+
'additionalClasses' => 'admin__field-date',
80+
]
81+
);
82+
$meta = $this->arrayManager->merge(
83+
$toFieldPath . self::META_CONFIG_PATH,
84+
$meta,
85+
[
86+
'label' => __('To'),
87+
'scopeLabel' => null,
88+
'additionalClasses' => 'admin__field-date',
89+
]
90+
);
91+
$meta = $this->arrayManager->merge(
92+
$fromContainerPath . self::META_CONFIG_PATH,
93+
$meta,
94+
[
95+
'label' => __('Schedule Update From'),
96+
'additionalClasses' => 'admin__control-grouped-date',
97+
'breakLine' => false,
98+
'component' => 'Magento_Ui/js/form/components/group',
99+
'scopeLabel' => $scopeLabel,
100+
]
101+
);
102+
$meta = $this->arrayManager->set(
103+
$fromContainerPath . '/children/' . self::CODE_CUSTOM_DESIGN_TO,
104+
$meta,
105+
$this->arrayManager->get($toFieldPath, $meta)
106+
);
83107

84-
]
85-
],
86-
],
87-
],
88-
'custom_design_to' => [
89-
'meta' => [
90-
'arguments' => [
91-
'data' => [
92-
'config' => [
93-
'label' => __('To'),
94-
'scopeLabel' => null,
95-
'additionalClasses' => 'admin__field-date',
96-
],
97-
]
98-
]
99-
]
100-
],
101-
[
102-
'targetCode' => 'custom_design_date_range',
103-
'meta' => [
104-
'arguments' => [
105-
'data' => [
106-
'label' => __('Schedule Update From'),
107-
'additionalClasses' => 'admin__control-grouped-date',
108-
'breakLine' => false,
109-
'scopeLabel' => $parentChildrenConfig['scopeLabel'],
110-
],
111-
],
112-
]
113-
],
114-
]
115-
);
116-
}
117-
118-
return $meta;
108+
return $this->arrayManager->remove($toContainerPath, $meta);
119109
}
120110
}

app/code/Magento/CatalogInventory/view/adminhtml/ui_component/product_form.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,8 @@
242242
<item name="value" xsi:type="number">0</item>
243243
<item name="sortOrder" xsi:type="number">600</item>
244244
<item name="scopeLabel" xsi:type="string">[GLOBAL]</item>
245-
<item name="quantityIncrements" xsi:type="string">index=qty_increments</item>
246-
<item name="minSaleQuantity" xsi:type="string">index=min_sale_qty</item>
245+
<item name="quantityIncrements" xsi:type="string">ns = ${ $.ns }, index=qty_increments</item>
246+
<item name="minSaleQuantity" xsi:type="string">ns = ${ $.ns }, index=min_sale_qty</item>
247247
<item name="imports" xsi:type="array">
248248
<item name="visible" xsi:type="string">${$.provider}:data.product.stock_data.manage_stock</item>
249249
</item>
@@ -290,7 +290,7 @@
290290
<argument name="data" xsi:type="array">
291291
<item name="config" xsi:type="array">
292292
<item name="component" xsi:type="string">Magento_CatalogInventory/js/components/backorders</item>
293-
<item name="deferredStockUpdate" xsi:type="string">index=container_deferred_stock_update</item>
293+
<item name="deferredStockUpdate" xsi:type="string">ns = ${ $.ns }, index=container_deferred_stock_update</item>
294294
<item name="formElement" xsi:type="string">select</item>
295295
<item name="dataScope" xsi:type="string">backorders</item>
296296
<item name="value" xsi:type="object">Magento\CatalogInventory\Model\Source\StockConfiguration</item>

app/code/Magento/Downloadable/Ui/DataProvider/Product/Form/Modifier/DownloadablePanel.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ protected function addCheckboxIsDownloadable()
126126
'false' => '0',
127127
'true' => '1',
128128
],
129-
'samplesFieldset' => 'index=' . Composite::CONTAINER_SAMPLES,
130-
'linksFieldset' => 'index=' . Composite::CONTAINER_LINKS,
129+
'samplesFieldset' => 'ns = ${ $.ns }, index=' . Composite::CONTAINER_SAMPLES,
130+
'linksFieldset' => 'ns = ${ $.ns }, index=' . Composite::CONTAINER_LINKS,
131131
];
132132
$hideConfig['arguments']['data']['config'] = [
133133
'dataType' => Form\Element\DataType\Number::NAME,

dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/ProductForm.php

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use Magento\Catalog\Test\Block\Adminhtml\Product\Attribute\CustomAttribute;
1212
use Magento\Catalog\Test\Fixture\CatalogProductAttribute;
1313
use Magento\Mtf\Client\Element\SimpleElement;
14-
use Magento\Catalog\Test\Block\Adminhtml\Product\Edit\ProductSection;
14+
use Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Section\Attributes;
1515
use Magento\Mtf\Client\Element;
1616
use Magento\Mtf\Client\Locator;
1717
use Magento\Mtf\Fixture\FixtureInterface;
@@ -45,13 +45,6 @@ class ProductForm extends FormSections
4545
*/
4646
protected $customSection = '.admin__collapsible-title';
4747

48-
/**
49-
* Tabs title css selector.
50-
*
51-
* @var string
52-
*/
53-
protected $tabsTitle = '#product_info_tabs-basic [data-role="title"]';
54-
5548
/**
5649
* Attribute block selector.
5750
*
@@ -289,19 +282,19 @@ public function getAttributeElement(CatalogProductAttribute $attribute)
289282
}
290283

291284
/**
292-
* Click "Add Attribute" button from specific tab.
285+
* Click "Add Attribute" button from specific section.
293286
*
294-
* @param string $tabName
287+
* @param string $sectionName
295288
* @throws \Exception
296289
*/
297-
public function addNewAttribute($tabName = 'product-details')
290+
public function addNewAttribute($sectionName = 'product-details')
298291
{
299-
$tab = $this->getSection($tabName);
300-
if ($tab instanceof ProductSection) {
301-
$this->openSection($tabName);
302-
$tab->addNewAttribute($tabName);
292+
$section = $this->getSection($sectionName);
293+
if ($section instanceof Attributes) {
294+
$this->openSection($sectionName);
295+
$section->addNewAttribute($sectionName);
303296
} else {
304-
throw new \Exception("$tabName hasn't 'Add attribute' button or is not instance of ProductSection class.");
297+
throw new \Exception("$sectionName hasn't 'Add attribute' button or is not instance of ProductSection class.");
305298
}
306299
}
307300
}

0 commit comments

Comments
 (0)