Skip to content

Commit 6907ef4

Browse files
author
Yuri Kovsher
committed
Merge remote-tracking branch 'tango-ce/MAGETWO-49187' into MAGETWO-48913
2 parents 5c8bace + 4a01531 commit 6907ef4

File tree

4 files changed

+154
-0
lines changed

4 files changed

+154
-0
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Bundle\Ui\DataProvider\Product\Form\Modifier;
7+
8+
use Magento\Catalog\Model\Locator\LocatorInterface;
9+
use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\AbstractModifier;
10+
use Magento\Bundle\Model\Product\Type;
11+
12+
/**
13+
* Class StockData hides unnecessary fields in Advanced Inventory Modal
14+
*/
15+
class StockData extends AbstractModifier
16+
{
17+
/**
18+
* @var LocatorInterface
19+
*/
20+
protected $locator;
21+
22+
/**
23+
* @param LocatorInterface $locator
24+
*/
25+
public function __construct(LocatorInterface $locator)
26+
{
27+
$this->locator = $locator;
28+
}
29+
30+
31+
/**
32+
* {@inheritdoc}
33+
*/
34+
public function modifyData(array $data)
35+
{
36+
return $data;
37+
}
38+
39+
/**
40+
* {@inheritdoc}
41+
*/
42+
public function modifyMeta(array $meta)
43+
{
44+
if ($this->locator->getProduct()->getTypeId() === Type::TYPE_CODE) {
45+
$config['arguments']['data']['config'] = [
46+
'visible' => 0,
47+
'imports' => [
48+
'visible' => null,
49+
],
50+
];
51+
52+
$meta['advanced_inventory_modal'] = [
53+
'children' => [
54+
'stock_data' => [
55+
'children' => [
56+
'qty' => $config,
57+
'container_min_qty' => $config,
58+
'container_min_sale_qty' => $config,
59+
'container_max_sale_qty' => $config,
60+
'is_qty_decimal' => $config,
61+
'is_decimal_divided' => $config,
62+
'container_backorders' => $config,
63+
'container_deferred_stock_update' => $config,
64+
'container_notify_stock_qty' => $config,
65+
],
66+
],
67+
],
68+
];
69+
}
70+
71+
return $meta;
72+
}
73+
}

app/code/Magento/Bundle/etc/adminhtml/di.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
<item name="class" xsi:type="string">Magento\Bundle\Ui\DataProvider\Product\Form\Modifier\Composite</item>
2727
<item name="sortOrder" xsi:type="number">125</item>
2828
</item>
29+
<item name="bundle_stock_data" xsi:type="array">
30+
<item name="class" xsi:type="string">Magento\Bundle\Ui\DataProvider\Product\Form\Modifier\StockData</item>
31+
<item name="sortOrder" xsi:type="number">126</item>
32+
</item>
2933
</argument>
3034
</arguments>
3135
</type>
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\GroupedProduct\Ui\DataProvider\Product\Form\Modifier;
7+
8+
use Magento\Catalog\Model\Locator\LocatorInterface;
9+
use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\AbstractModifier;
10+
use Magento\GroupedProduct\Model\Product\Type\Grouped as GroupedProductType;
11+
12+
/**
13+
* Class StockData hides unnecessary fields in Advanced Inventory Modal
14+
*/
15+
class StockData extends AbstractModifier
16+
{
17+
/**
18+
* @var LocatorInterface
19+
*/
20+
protected $locator;
21+
22+
/**
23+
* @param LocatorInterface $locator
24+
*/
25+
public function __construct(LocatorInterface $locator)
26+
{
27+
$this->locator = $locator;
28+
}
29+
30+
31+
/**
32+
* {@inheritdoc}
33+
*/
34+
public function modifyData(array $data)
35+
{
36+
return $data;
37+
}
38+
39+
/**
40+
* {@inheritdoc}
41+
*/
42+
public function modifyMeta(array $meta)
43+
{
44+
if ($this->locator->getProduct()->getTypeId() === GroupedProductType::TYPE_CODE) {
45+
$config['arguments']['data']['config'] = [
46+
'visible' => 0,
47+
'imports' => [
48+
'visible' => null,
49+
],
50+
];
51+
52+
$meta['advanced_inventory_modal'] = [
53+
'children' => [
54+
'stock_data' => [
55+
'children' => [
56+
'qty' => $config,
57+
'container_min_qty' => $config,
58+
'container_min_sale_qty' => $config,
59+
'container_max_sale_qty' => $config,
60+
'is_qty_decimal' => $config,
61+
'is_decimal_divided' => $config,
62+
'container_backorders' => $config,
63+
'container_deferred_stock_update' => $config,
64+
'container_notify_stock_qty' => $config,
65+
],
66+
],
67+
],
68+
];
69+
}
70+
71+
return $meta;
72+
}
73+
}

app/code/Magento/GroupedProduct/etc/adminhtml/di.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
<item name="class" xsi:type="string">Magento\GroupedProduct\Ui\DataProvider\Product\Form\Modifier\Grouped</item>
2828
<item name="sortOrder" xsi:type="number">120</item>
2929
</item>
30+
<item name="grouped_stock_data" xsi:type="array">
31+
<item name="class" xsi:type="string">Magento\GroupedProduct\Ui\DataProvider\Product\Form\Modifier\StockData</item>
32+
<item name="sortOrder" xsi:type="number">121</item>
33+
</item>
3034
</argument>
3135
</arguments>
3236
</type>

0 commit comments

Comments
 (0)