Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 8e38439

Browse files
🔃 [EngCom] Public Pull Requests - 2.3-develop
Accepted Public Pull Requests: - magento/magento2#20231: Fix #20229-Fatal error on product-compare page when attributes not configured (by @vivekkumarcedcoss) - magento/magento2#20408: aclResource for UIComponent buttons (by @kassner) - magento/magento2#20407: Tier price on configurable product sorting sometimes wrong (by @vshatylo) - magento/magento2#20349: Fixed #19258 Incorrect orders updated (by @shikhamis11) - magento/magento2#19997: 19482 increase product quantity with disabled manage stock when place order is failed (by @agorbulin) - magento/magento2#19822: magento/magento2#?: Mark not used downloadable blocks, tests, layout updates and templates as deprecated. (by @swnsma) - magento/magento2#19095: Fix mass product update with group min cart qty (by @pmclain) - magento/magento2#19372: fixed Negative order amount in dashboard - #18754 (by @niravkrish) - magento/magento2#19585: Avoid duplicate loading of configuration files (by @ajardin) Fixed GitHub Issues: - magento/magento2#20229: Fatal error on product-compare page when attributes not configured (reported by @Brengineer) has been fixed in magento/magento2#20231 by @vivekkumarcedcoss in 2.3-develop branch Related commits: 1. db0e8b2 - magento/magento2#12194: Tier price on configurable product sorting sometimes wrong (reported by @matin73) has been fixed in magento/magento2#20407 by @vshatylo in 2.3-develop branch Related commits: 1. f4d0947 - magento/magento2#19258: Incorrect orders updated (reported by @shachiarkatkar) has been fixed in magento/magento2#20349 by @shikhamis11 in 2.3-develop branch Related commits: 1. 56c1b33 2. d55f47d - magento/magento2#19482: Increase product quantity with disabled Manage Stock when place order is failed (reported by @iGerchak) has been fixed in magento/magento2#19997 by @agorbulin in 2.3-develop branch Related commits: 1. c608b02 2. 1a5a6be 3. eb60f47 - magento/magento2#17592: Mass attribute update fails with E_WARNING (reported by @sabl0r) has been fixed in magento/magento2#19095 by @pmclain in 2.3-develop branch Related commits: 1. cf383a9 2. e945ba0 3. b3a4058 - magento/magento2#18754: Negative order amount in dashboard latest order when order is cancelled where coupon has been used (reported by @albsa) has been fixed in magento/magento2#19372 by @niravkrish in 2.3-develop branch Related commits: 1. c4f9a02 2. 6ad2344
2 parents bbb1a60 + cef9380 commit 8e38439

File tree

37 files changed

+331
-59
lines changed

37 files changed

+331
-59
lines changed

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

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

8+
use Magento\Customer\Api\Data\GroupInterface;
9+
810
/**
911
* Products mass update inventory tab
1012
*
@@ -29,20 +31,29 @@ class Inventory extends \Magento\Backend\Block\Widget implements \Magento\Backen
2931
*/
3032
protected $disabledFields = [];
3133

34+
/**
35+
* @var \Magento\Framework\Serialize\SerializerInterface
36+
*/
37+
private $serializer;
38+
3239
/**
3340
* @param \Magento\Backend\Block\Template\Context $context
3441
* @param \Magento\CatalogInventory\Model\Source\Backorders $backorders
3542
* @param \Magento\CatalogInventory\Api\StockConfigurationInterface $stockConfiguration
3643
* @param array $data
44+
* @param \Magento\Framework\Serialize\SerializerInterface|null $serializer
3745
*/
3846
public function __construct(
3947
\Magento\Backend\Block\Template\Context $context,
4048
\Magento\CatalogInventory\Model\Source\Backorders $backorders,
4149
\Magento\CatalogInventory\Api\StockConfigurationInterface $stockConfiguration,
42-
array $data = []
50+
array $data = [],
51+
\Magento\Framework\Serialize\SerializerInterface $serializer = null
4352
) {
4453
$this->_backorders = $backorders;
4554
$this->stockConfiguration = $stockConfiguration;
55+
$this->serializer = $serializer ?? \Magento\Framework\App\ObjectManager::getInstance()
56+
->get(\Magento\Framework\Serialize\SerializerInterface::class);
4657
parent::__construct($context, $data);
4758
}
4859

@@ -70,11 +81,13 @@ public function getFieldSuffix()
7081
* Retrieve current store id
7182
*
7283
* @return int
84+
* @SuppressWarnings(PHPMD.RequestAwareBlockMethod)
7385
*/
7486
public function getStoreId()
7587
{
76-
$storeId = $this->getRequest()->getParam('store');
77-
return (int) $storeId;
88+
$storeId = (int)$this->getRequest()->getParam('store');
89+
90+
return $storeId;
7891
}
7992

8093
/**
@@ -88,6 +101,22 @@ public function getDefaultConfigValue($field)
88101
return $this->stockConfiguration->getDefaultConfigValue($field);
89102
}
90103

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+
91120
/**
92121
* Tab settings
93122
*
@@ -99,6 +128,8 @@ public function getTabLabel()
99128
}
100129

101130
/**
131+
* Return Tab title.
132+
*
102133
* @return \Magento\Framework\Phrase
103134
*/
104135
public function getTabTitle()
@@ -107,22 +138,24 @@ public function getTabTitle()
107138
}
108139

109140
/**
110-
* @return bool
141+
* @inheritdoc
111142
*/
112143
public function canShowTab()
113144
{
114145
return true;
115146
}
116147

117148
/**
118-
* @return bool
149+
* @inheritdoc
119150
*/
120151
public function isHidden()
121152
{
122153
return false;
123154
}
124155

125156
/**
157+
* Get availability status.
158+
*
126159
* @param string $fieldName
127160
* @return bool
128161
* @SuppressWarnings(PHPMD.UnusedFormalParameter)

app/code/Magento/Catalog/Model/Category/Attribute/Source/Layout.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ class Layout extends \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource
1717
*/
1818
protected $pageLayoutBuilder;
1919

20+
/**
21+
* @inheritdoc
22+
* @deprecated since the cache is now handled by \Magento\Theme\Model\PageLayout\Config\Builder::$configFiles
23+
*/
24+
protected $_options = null;
25+
2026
/**
2127
* @param \Magento\Framework\View\Model\PageLayout\Config\BuilderInterface $pageLayoutBuilder
2228
*/
@@ -26,14 +32,14 @@ public function __construct(\Magento\Framework\View\Model\PageLayout\Config\Buil
2632
}
2733

2834
/**
29-
* {@inheritdoc}
35+
* @inheritdoc
3036
*/
3137
public function getAllOptions()
3238
{
33-
if (!$this->_options) {
34-
$this->_options = $this->pageLayoutBuilder->getPageLayoutsConfig()->toOptionArray();
35-
array_unshift($this->_options, ['value' => '', 'label' => __('No layout updates')]);
36-
}
37-
return $this->_options;
39+
$options = $this->pageLayoutBuilder->getPageLayoutsConfig()->toOptionArray();
40+
array_unshift($options, ['value' => '', 'label' => __('No layout updates')]);
41+
$this->_options = $options;
42+
43+
return $options;
3844
}
3945
}

app/code/Magento/Catalog/Model/Product/Attribute/Source/Layout.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ class Layout extends \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource
1717
*/
1818
protected $pageLayoutBuilder;
1919

20+
/**
21+
* @inheritdoc
22+
* @deprecated since the cache is now handled by \Magento\Theme\Model\PageLayout\Config\Builder::$configFiles
23+
*/
24+
protected $_options = null;
25+
2026
/**
2127
* @param \Magento\Framework\View\Model\PageLayout\Config\BuilderInterface $pageLayoutBuilder
2228
*/
@@ -26,14 +32,14 @@ public function __construct(\Magento\Framework\View\Model\PageLayout\Config\Buil
2632
}
2733

2834
/**
29-
* @return array
35+
* @inheritdoc
3036
*/
3137
public function getAllOptions()
3238
{
33-
if (!$this->_options) {
34-
$this->_options = $this->pageLayoutBuilder->getPageLayoutsConfig()->toOptionArray();
35-
array_unshift($this->_options, ['value' => '', 'label' => __('No layout updates')]);
36-
}
37-
return $this->_options;
39+
$options = $this->pageLayoutBuilder->getPageLayoutsConfig()->toOptionArray();
40+
array_unshift($options, ['value' => '', 'label' => __('No layout updates')]);
41+
$this->_options = $options;
42+
43+
return $options;
3844
}
3945
}

app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2218,7 +2218,7 @@ private function getTierPriceSelect(array $productIds)
22182218
$this->getLinkField() . ' IN(?)',
22192219
$productIds
22202220
)->order(
2221-
$this->getLinkField()
2221+
'qty'
22222222
);
22232223
return $select;
22242224
}

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

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

8+
use Magento\Customer\Api\Data\GroupInterface;
9+
810
/**
911
* Class InventoryTest
1012
*/
@@ -68,7 +70,8 @@ protected function setUp()
6870
[
6971
'context' => $this->contextMock,
7072
'backorders' => $this->backordersMock,
71-
'stockConfiguration' => $this->stockConfigurationMock
73+
'stockConfiguration' => $this->stockConfigurationMock,
74+
'serializer' => new \Magento\Framework\Serialize\Serializer\Json(),
7275
]
7376
);
7477
}
@@ -126,6 +129,32 @@ public function testGetDefaultConfigValue()
126129
$this->assertEquals('return-value', $this->inventory->getDefaultConfigValue('field-name'));
127130
}
128131

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+
129158
/**
130159
* Run test getTabLabel method
131160
*

app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/CollectionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ public function testAddTierPriceDataByGroupId()
323323
[ '(customer_group_id=? AND all_groups=0) OR all_groups=1', $customerGroupId]
324324
)
325325
->willReturnSelf();
326-
$select->expects($this->once())->method('order')->with('entity_id')->willReturnSelf();
326+
$select->expects($this->once())->method('order')->with('qty')->willReturnSelf();
327327
$this->connectionMock->expects($this->once())
328328
->method('fetchAll')
329329
->with($select)
@@ -375,7 +375,7 @@ public function testAddTierPriceData()
375375
$select->expects($this->exactly(1))->method('where')
376376
->with('entity_id IN(?)', [1])
377377
->willReturnSelf();
378-
$select->expects($this->once())->method('order')->with('entity_id')->willReturnSelf();
378+
$select->expects($this->once())->method('order')->with('qty')->willReturnSelf();
379379
$this->connectionMock->expects($this->once())
380380
->method('fetchAll')
381381
->with($select)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@
132132
<div class="field">
133133
<input type="text" class="input-text validate-number" id="inventory_min_sale_qty"
134134
name="<?= /* @escapeNotVerified */ $block->getFieldSuffix() ?>[min_sale_qty]"
135-
value="<?= /* @escapeNotVerified */ $block->getDefaultConfigValue('min_sale_qty') * 1 ?>"
135+
value="<?= /* @escapeNotVerified */ $block->getDefaultMinSaleQty() * 1 ?>"
136136
disabled="disabled"/>
137137
</div>
138138
<div class="field choice">

app/code/Magento/Catalog/view/frontend/templates/product/compare/list.phtml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,9 @@
116116
<?php $block->getImage($item, 'product_small_image')->toHtml(); ?>
117117
<?php break;
118118
default: ?>
119-
<?= /* @escapeNotVerified */ $helper->productAttribute($item, $block->getProductAttributeValue($item, $attribute), $attribute->getAttributeCode()) ?>
119+
<?php if (is_string($block->getProductAttributeValue($item, $attribute))): ?>
120+
<?= /* @escapeNotVerified */ $helper->productAttribute($item, $block->getProductAttributeValue($item, $attribute), $attribute->getAttributeCode()) ?>
121+
<?php endif; ?>
120122
<?php break;
121123
} ?>
122124
</div>

app/code/Magento/CatalogInventory/Model/StockManagement.php

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ public function __construct(
8585

8686
/**
8787
* Subtract product qtys from stock.
88+
*
8889
* Return array of items that require full save.
8990
*
9091
* @param string[] $items
@@ -141,17 +142,25 @@ public function registerProductsSale($items, $websiteId = null)
141142
}
142143

143144
/**
144-
* @param string[] $items
145-
* @param int $websiteId
146-
* @return bool
145+
* @inheritdoc
147146
*/
148147
public function revertProductsSale($items, $websiteId = null)
149148
{
150149
//if (!$websiteId) {
151150
$websiteId = $this->stockConfiguration->getDefaultScopeId();
152151
//}
153-
$this->qtyCounter->correctItemsQty($items, $websiteId, '+');
154-
return true;
152+
$revertItems = [];
153+
foreach ($items as $productId => $qty) {
154+
$stockItem = $this->stockRegistryProvider->getStockItem($productId, $websiteId);
155+
$canSubtractQty = $stockItem->getItemId() && $this->canSubtractQty($stockItem);
156+
if (!$canSubtractQty || !$this->stockConfiguration->isQty($stockItem->getTypeId())) {
157+
continue;
158+
}
159+
$revertItems[$productId] = $qty;
160+
}
161+
$this->qtyCounter->correctItemsQty($revertItems, $websiteId, '+');
162+
163+
return $revertItems;
155164
}
156165

157166
/**
@@ -195,6 +204,8 @@ protected function getProductType($productId)
195204
}
196205

197206
/**
207+
* Get stock resource.
208+
*
198209
* @return ResourceStock
199210
*/
200211
protected function getResource()

app/code/Magento/CatalogInventory/Observer/RevertQuoteInventoryObserver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ public function execute(EventObserver $observer)
6464
{
6565
$quote = $observer->getEvent()->getQuote();
6666
$items = $this->productQty->getProductQty($quote->getAllItems());
67-
$this->stockManagement->revertProductsSale($items, $quote->getStore()->getWebsiteId());
68-
$productIds = array_keys($items);
67+
$revertedItems = $this->stockManagement->revertProductsSale($items, $quote->getStore()->getWebsiteId());
68+
$productIds = array_keys($revertedItems);
6969
if (!empty($productIds)) {
7070
$this->stockIndexerProcessor->reindexList($productIds);
7171
$this->priceIndexer->reindexList($productIds);

app/code/Magento/Cms/Model/Page/Source/PageLayout.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class PageLayout implements OptionSourceInterface
2020

2121
/**
2222
* @var array
23+
* @deprecated since the cache is now handled by \Magento\Theme\Model\PageLayout\Config\Builder::$configFiles
2324
*/
2425
protected $options;
2526

@@ -34,16 +35,10 @@ public function __construct(BuilderInterface $pageLayoutBuilder)
3435
}
3536

3637
/**
37-
* Get options
38-
*
39-
* @return array
38+
* @inheritdoc
4039
*/
4140
public function toOptionArray()
4241
{
43-
if ($this->options !== null) {
44-
return $this->options;
45-
}
46-
4742
$configOptions = $this->pageLayoutBuilder->getPageLayoutsConfig()->getOptions();
4843
$options = [];
4944
foreach ($configOptions as $key => $value) {
@@ -54,6 +49,6 @@ public function toOptionArray()
5449
}
5550
$this->options = $options;
5651

57-
return $this->options;
52+
return $options;
5853
}
5954
}

app/code/Magento/Downloadable/Block/Adminhtml/Catalog/Product/Composite/Fieldset/Downloadable.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,15 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
/**
8-
* Adminhtml block for fieldset of downloadable product
9-
*
10-
* @author Magento Core Team <[email protected]>
11-
*/
127
namespace Magento\Downloadable\Block\Adminhtml\Catalog\Product\Composite\Fieldset;
138

149
/**
10+
* Adminhtml block for fieldset of downloadable product
11+
*
1512
* @api
1613
* @since 100.0.2
14+
* @deprecated
15+
* @see \Magento\Downloadable\Ui\DataProvider\Product\Form\Modifier\Composite
1716
*/
1817
class Downloadable extends \Magento\Downloadable\Block\Catalog\Product\Links
1918
{

0 commit comments

Comments
 (0)