Skip to content

Commit 292d816

Browse files
committed
Merge remote-tracking branch 'borg/MC-13875' into MC-13852
2 parents 67a2a4d + 0fd425f commit 292d816

File tree

3 files changed

+11
-62
lines changed
  • app/code/Magento/Catalog

3 files changed

+11
-62
lines changed

app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Action/Attribute/Tab/Inventory.php

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
*/
66
namespace Magento\Catalog\Block\Adminhtml\Product\Edit\Action\Attribute\Tab;
77

8-
use Magento\Customer\Api\Data\GroupInterface;
9-
108
/**
119
* Products mass update inventory tab
1210
*
@@ -31,29 +29,20 @@ class Inventory extends \Magento\Backend\Block\Widget implements \Magento\Backen
3129
*/
3230
protected $disabledFields = [];
3331

34-
/**
35-
* @var \Magento\Framework\Serialize\SerializerInterface
36-
*/
37-
private $serializer;
38-
3932
/**
4033
* @param \Magento\Backend\Block\Template\Context $context
4134
* @param \Magento\CatalogInventory\Model\Source\Backorders $backorders
4235
* @param \Magento\CatalogInventory\Api\StockConfigurationInterface $stockConfiguration
4336
* @param array $data
44-
* @param \Magento\Framework\Serialize\SerializerInterface|null $serializer
4537
*/
4638
public function __construct(
4739
\Magento\Backend\Block\Template\Context $context,
4840
\Magento\CatalogInventory\Model\Source\Backorders $backorders,
4941
\Magento\CatalogInventory\Api\StockConfigurationInterface $stockConfiguration,
50-
array $data = [],
51-
\Magento\Framework\Serialize\SerializerInterface $serializer = null
42+
array $data = []
5243
) {
5344
$this->_backorders = $backorders;
5445
$this->stockConfiguration = $stockConfiguration;
55-
$this->serializer = $serializer ?? \Magento\Framework\App\ObjectManager::getInstance()
56-
->get(\Magento\Framework\Serialize\SerializerInterface::class);
5746
parent::__construct($context, $data);
5847
}
5948

@@ -85,9 +74,7 @@ public function getFieldSuffix()
8574
*/
8675
public function getStoreId()
8776
{
88-
$storeId = (int)$this->getRequest()->getParam('store');
89-
90-
return $storeId;
77+
return (int)$this->getRequest()->getParam('store');
9178
}
9279

9380
/**
@@ -101,22 +88,6 @@ public function getDefaultConfigValue($field)
10188
return $this->stockConfiguration->getDefaultConfigValue($field);
10289
}
10390

104-
/**
105-
* Returns min_sale_qty configuration for the ALL Customer Group
106-
*
107-
* @return float
108-
*/
109-
public function getDefaultMinSaleQty()
110-
{
111-
$default = $this->stockConfiguration->getDefaultConfigValue('min_sale_qty');
112-
if (!is_numeric($default)) {
113-
$default = $this->serializer->unserialize($default);
114-
$default = $default[GroupInterface::CUST_GROUP_ALL] ?? 1;
115-
}
116-
117-
return (float) $default;
118-
}
119-
12091
/**
12192
* Tab settings
12293
*

app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Edit/Action/Attribute/Tab/InventoryTest.php

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
*/
66
namespace Magento\Catalog\Test\Unit\Block\Adminhtml\Product\Edit\Action\Attribute\Tab;
77

8-
use Magento\Customer\Api\Data\GroupInterface;
9-
108
/**
119
* Class InventoryTest
1210
*/
@@ -70,8 +68,7 @@ protected function setUp()
7068
[
7169
'context' => $this->contextMock,
7270
'backorders' => $this->backordersMock,
73-
'stockConfiguration' => $this->stockConfigurationMock,
74-
'serializer' => new \Magento\Framework\Serialize\Serializer\Json(),
71+
'stockConfiguration' => $this->stockConfigurationMock
7572
]
7673
);
7774
}
@@ -129,32 +126,6 @@ public function testGetDefaultConfigValue()
129126
$this->assertEquals('return-value', $this->inventory->getDefaultConfigValue('field-name'));
130127
}
131128

132-
/**
133-
* @dataProvider getDefaultMinSaleQtyDataProvider
134-
* @param string $expected
135-
* @param string $default
136-
*/
137-
public function testGetDefaultMinSaleQty($expected, $default)
138-
{
139-
$this->stockConfigurationMock->method('getDefaultConfigValue')->willReturn($default);
140-
$this->assertEquals($expected, $this->inventory->getDefaultMinSaleQty());
141-
}
142-
143-
public function getDefaultMinSaleQtyDataProvider()
144-
{
145-
return [
146-
'single-default-value' => [
147-
22, '22'
148-
],
149-
'no-default-for-all-group' => [
150-
1, json_encode(['12' => '111'])
151-
],
152-
'default-for-all-group' => [
153-
5, json_encode(['12' => '111', GroupInterface::CUST_GROUP_ALL => '5'])
154-
]
155-
];
156-
}
157-
158129
/**
159130
* Run test getTabLabel method
160131
*

app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/edit/action/inventory.phtml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@
3030
});
3131
</script>
3232

33+
<?php
34+
$defaultMinSaleQty = $block->getDefaultConfigValue('min_sale_qty');
35+
if (!is_numeric($defaultMinSaleQty)) {
36+
$defaultMinSaleQty = json_decode($defaultMinSaleQty, true);
37+
$defaultMinSaleQty = (float) $defaultMinSaleQty[\Magento\Customer\Api\Data\GroupInterface::CUST_GROUP_ALL] ?? 1;
38+
}
39+
?>
3340
<div class="fieldset-wrapper form-inline advanced-inventory-edit">
3441
<div class="fieldset-wrapper-title">
3542
<strong class="title">
@@ -132,7 +139,7 @@
132139
<div class="field">
133140
<input type="text" class="input-text validate-number" id="inventory_min_sale_qty"
134141
name="<?= /* @escapeNotVerified */ $block->getFieldSuffix() ?>[min_sale_qty]"
135-
value="<?= /* @escapeNotVerified */ $block->getDefaultMinSaleQty() * 1 ?>"
142+
value="<?= /* @escapeNotVerified */ $defaultMinSaleQty ?>"
136143
disabled="disabled"/>
137144
</div>
138145
<div class="field choice">

0 commit comments

Comments
 (0)