Skip to content

Commit f65e571

Browse files
committed
Merge remote-tracking branch 'mainline/2.3-develop' into MC-18190
2 parents 147a043 + c6427d1 commit f65e571

File tree

7 files changed

+79
-18
lines changed

7 files changed

+79
-18
lines changed

app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Initialization/Helper/Plugin/UpdateConfigurations.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
*/
88
namespace Magento\ConfigurableProduct\Controller\Adminhtml\Product\Initialization\Helper\Plugin;
99

10+
use \Magento\Catalog\Model\Product\Edit\WeightResolver;
11+
12+
/**
13+
* Update Configurations for configurable product
14+
*/
1015
class UpdateConfigurations
1116
{
1217
/**
@@ -110,6 +115,12 @@ protected function getConfigurations()
110115
if (isset($item['qty'])) {
111116
$result[$item['id']]['quantity_and_stock_status']['qty'] = $item['qty'];
112117
}
118+
119+
// Changing product to simple on weight change
120+
if (isset($item['weight']) && $item['weight'] >= 0) {
121+
$result[$item['id']]['type_id'] = \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE;
122+
$result[$item['id']]['product_has_weight'] = WeightResolver::HAS_WEIGHT;
123+
}
113124
}
114125
}
115126
}

app/code/Magento/ConfigurableProduct/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin/UpdateConfigurationsTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,9 @@ public function testAfterInitialize()
136136
'swatch_image' => 'simple2_swatch_image',
137137
'small_image' => 'simple2_small_image',
138138
'thumbnail' => 'simple2_thumbnail',
139-
'image' => 'simple2_image'
139+
'image' => 'simple2_image',
140+
'product_has_weight' => 1,
141+
'type_id' => 'simple'
140142
],
141143
'product3' => [
142144
'quantity_and_stock_status' => ['qty' => '3']

app/code/Magento/Customer/view/frontend/templates/address/grid.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ $customerAddressView = $block->getData('customer_address');
6363
<button type="button" role="add-address" title="<?= $block->escapeHtmlAttr(__('Add New Address')) ?>" class="action primary add"><span><?= $block->escapeHtml(__('Add New Address')) ?></span></button>
6464
</div>
6565
<div class="secondary">
66-
<a class="action back" href="<?= $block->escapeUrl($block->getBackUrl()) ?>"><span><?= $block->escapeHtml(__('Back')) ?></span></a>
66+
<a class="action back" href="<?= $block->escapeUrl($block->getUrl('customer/account')) ?>"><span><?= $block->escapeHtml(__('Back')) ?></span></a>
6767
</div>
6868
</div>
6969
<script type="text/x-magento-init">

app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/FieldMapperResolver.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
use Magento\Elasticsearch\Model\Adapter\FieldMapperInterface;
1010
use Magento\Elasticsearch\Model\Config;
1111

12+
/**
13+
* Field Mapper resolver.
14+
*/
1215
class FieldMapperResolver implements FieldMapperInterface
1316
{
1417
/**
@@ -24,11 +27,11 @@ class FieldMapperResolver implements FieldMapperInterface
2427
private $fieldMappers;
2528

2629
/**
27-
* Field Mapper instance
30+
* Field Mapper instance per entity
2831
*
29-
* @var FieldMapperInterface
32+
* @var FieldMapperInterface[]
3033
*/
31-
private $fieldMapperEntity;
34+
private $fieldMapperEntity = [];
3235

3336
/**
3437
* @param ObjectManagerInterface $objectManager
@@ -43,7 +46,7 @@ public function __construct(
4346
}
4447

4548
/**
46-
* {@inheritdoc}
49+
* @inheritdoc
4750
*/
4851
public function getFieldName($attributeCode, $context = [])
4952
{
@@ -52,7 +55,7 @@ public function getFieldName($attributeCode, $context = [])
5255
}
5356

5457
/**
55-
* {@inheritdoc}
58+
* @inheritdoc
5659
*/
5760
public function getAllAttributesTypes($context = [])
5861
{
@@ -69,8 +72,9 @@ public function getAllAttributesTypes($context = [])
6972
*/
7073
private function getEntity($entityType)
7174
{
72-
if (empty($this->fieldMapperEntity)) {
75+
if (empty($this->fieldMapperEntity[$entityType])) {
7376
if (empty($entityType)) {
77+
// phpcs:ignore Magento2.Exceptions.DirectThrow
7478
throw new \Exception(
7579
'No entity type given'
7680
);
@@ -81,13 +85,13 @@ private function getEntity($entityType)
8185
);
8286
}
8387
$fieldMapperClass = $this->fieldMappers[$entityType];
84-
$this->fieldMapperEntity = $this->objectManager->create($fieldMapperClass);
85-
if (!($this->fieldMapperEntity instanceof FieldMapperInterface)) {
88+
$this->fieldMapperEntity[$entityType] = $this->objectManager->create($fieldMapperClass);
89+
if (!($this->fieldMapperEntity[$entityType] instanceof FieldMapperInterface)) {
8690
throw new \InvalidArgumentException(
8791
'Field mapper must implement \Magento\Elasticsearch\Model\Adapter\FieldMapperInterface'
8892
);
8993
}
9094
}
91-
return $this->fieldMapperEntity;
95+
return $this->fieldMapperEntity[$entityType];
9296
}
9397
}

app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Coupons/Form.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab\Coupons;
79

810
/**
911
* Coupons generation parameters form
1012
*
1113
* @author Magento Core Team <core@magentocommerce.com>
14+
*
15+
* Class \Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab\Coupons\Form
1216
*/
1317
class Form extends \Magento\Backend\Block\Widget\Form\Generic
1418
{
@@ -77,7 +81,8 @@ protected function _prepareForm()
7781
'label' => __('Coupon Qty'),
7882
'title' => __('Coupon Qty'),
7983
'required' => true,
80-
'class' => 'validate-digits validate-greater-than-zero'
84+
'class' => 'validate-digits validate-greater-than-zero',
85+
'onchange' => 'window.validateCouponGenerate(this)'
8186
]
8287
);
8388

@@ -91,7 +96,8 @@ protected function _prepareForm()
9196
'required' => true,
9297
'note' => __('Excluding prefix, suffix and separators.'),
9398
'value' => $couponHelper->getDefaultLength(),
94-
'class' => 'validate-digits validate-greater-than-zero'
99+
'class' => 'validate-digits validate-greater-than-zero',
100+
'onchange' => 'window.validateCouponGenerate(this)'
95101
]
96102
);
97103

@@ -103,7 +109,8 @@ protected function _prepareForm()
103109
'name' => 'format',
104110
'options' => $couponHelper->getFormatsList(),
105111
'required' => true,
106-
'value' => $couponHelper->getDefaultFormat()
112+
'value' => $couponHelper->getDefaultFormat(),
113+
'onchange' => 'window.validateCouponGenerate(this)'
107114
]
108115
);
109116

@@ -138,7 +145,8 @@ protected function _prepareForm()
138145
'title' => __('Dash Every X Characters'),
139146
'note' => __('If empty no separation.'),
140147
'value' => $couponHelper->getDefaultDashInterval(),
141-
'class' => 'validate-digits'
148+
'class' => 'validate-digits',
149+
'onchange' => 'window.validateCouponGenerate(this)'
142150
]
143151
);
144152

app/code/Magento/SalesRule/view/adminhtml/templates/promo/salesrulejs.phtml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,19 @@ function refreshCouponCodesGrid(grid, gridMassAction, transport) {
2020

2121
function generateCouponCodes(idPrefix, generateUrl, grid) {
2222
$(idPrefix + 'information_fieldset').removeClassName('ignore-validate');
23+
var listInvalidElement = [];
2324
var validationResult = $(idPrefix + 'information_fieldset').select('input',
2425
'select', 'textarea').collect( function(elm) {
25-
return jQuery.validator.validateElement(elm);
26+
var validateOneElementResult = jQuery.validator.validateSingleElement(elm);
27+
if (!validateOneElementResult) {
28+
listInvalidElement.push(elm);
29+
}
30+
return validateOneElementResult;
2631
}).all();
32+
if (listInvalidElement.length) {
33+
listInvalidElement[0].focus();
34+
}
35+
2736
$(idPrefix + 'information_fieldset').addClassName('ignore-validate');
2837

2938
if (!validationResult) {
@@ -77,6 +86,11 @@ function generateCouponCodes(idPrefix, generateUrl, grid) {
7786
});
7887
}
7988

89+
function validateCouponGenerate(elm) {
90+
jQuery.validator.validateSingleElement(elm);
91+
}
92+
93+
window.validateCouponGenerate = validateCouponGenerate;
8094
window.generateCouponCodes = generateCouponCodes;
8195
window.refreshCouponCodesGrid = refreshCouponCodesGrid;
8296
});

app/code/Magento/Tax/Block/Sales/Order/Tax.php

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
use Magento\Sales\Model\Order;
1313

1414
/**
15+
* Tax totals modification block.
16+
*
1517
* @api
1618
* @since 100.0.2
1719
*/
@@ -103,6 +105,10 @@ public function initTotals()
103105
protected function _addTax($after = 'discount')
104106
{
105107
$taxTotal = new \Magento\Framework\DataObject(['code' => 'tax', 'block_name' => $this->getNameInLayout()]);
108+
$totals = $this->getParentBlock()->getTotals();
109+
if ($totals['grand_total']) {
110+
$this->getParentBlock()->addTotalBefore($taxTotal, 'grand_total');
111+
}
106112
$this->getParentBlock()->addTotal($taxTotal, $after);
107113
return $this;
108114
}
@@ -118,6 +124,8 @@ public function getStore()
118124
}
119125

120126
/**
127+
* Initialization grand total.
128+
*
121129
* @return $this
122130
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
123131
*/
@@ -199,6 +207,8 @@ protected function _initSubtotal()
199207
}
200208

201209
/**
210+
* Init shipping.
211+
*
202212
* @return $this
203213
*/
204214
protected function _initShipping()
@@ -260,13 +270,19 @@ protected function _initShipping()
260270
}
261271

262272
/**
273+
* Init discount.
274+
*
275+
* phpcs:disable Magento2.CodeAnalysis.EmptyBlock
276+
*
263277
* @return void
264278
*/
265279
protected function _initDiscount()
266280
{
267281
}
268-
282+
//phpcs:enable
269283
/**
284+
* Init grand total.
285+
*
270286
* @return $this
271287
*/
272288
protected function _initGrandTotal()
@@ -304,13 +320,15 @@ protected function _initGrandTotal()
304320
]
305321
);
306322
$parent->addTotal($totalExcl, 'grand_total');
307-
$this->_addTax('grand_total');
308323
$parent->addTotal($totalIncl, 'tax');
324+
$this->_addTax('grand_total');
309325
}
310326
return $this;
311327
}
312328

313329
/**
330+
* Return order.
331+
*
314332
* @return Order
315333
*/
316334
public function getOrder()
@@ -319,6 +337,8 @@ public function getOrder()
319337
}
320338

321339
/**
340+
* Return label properties.
341+
*
322342
* @return array
323343
*/
324344
public function getLabelProperties()
@@ -327,6 +347,8 @@ public function getLabelProperties()
327347
}
328348

329349
/**
350+
* Retuen value properties.
351+
*
330352
* @return array
331353
*/
332354
public function getValueProperties()

0 commit comments

Comments
 (0)