Skip to content

Commit 90bcfb3

Browse files
committed
Merge remote-tracking branch 'origin/2.4-develop' into MC-31618-2
2 parents c9ed41b + ad41c3b commit 90bcfb3

File tree

70 files changed

+4195
-259
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+4195
-259
lines changed

app/code/Magento/Catalog/Model/Product/Price/Validation/Result.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ public function getFailedItems()
8383
}
8484
}
8585

86+
/**
87+
* Clear validation messages to prevent wrong validation for subsequent price update.
88+
* Work around for backward compatible changes.
89+
*/
90+
$this->failedItems = [];
91+
8692
return $failedItems;
8793
}
8894
}

app/code/Magento/Catalog/Model/ResourceModel/Category/AggregateCount.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,15 @@
88
use Magento\Catalog\Model\Category;
99

1010
/**
11+
* Aggregate count for parent category after deleting child category
12+
*
1113
* Class AggregateCount
1214
*/
1315
class AggregateCount
1416
{
1517
/**
18+
* Reduces children count for parent categories
19+
*
1620
* @param Category $category
1721
* @return void
1822
*/
@@ -25,9 +29,7 @@ public function processDelete(Category $category)
2529
*/
2630
$parentIds = $category->getParentIds();
2731
if ($parentIds) {
28-
$childDecrease = $category->getChildrenCount() + 1;
29-
// +1 is itself
30-
$data = ['children_count' => new \Zend_Db_Expr('children_count - ' . $childDecrease)];
32+
$data = ['children_count' => new \Zend_Db_Expr('children_count - 1')];
3133
$where = ['entity_id IN(?)' => $parentIds];
3234
$resourceModel->getConnection()->update($resourceModel->getEntityTable(), $data, $where);
3335
}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Catalog\Test\Unit\Model\ResourceModel\Category;
9+
10+
use Magento\Catalog\Model\Category;
11+
use Magento\Catalog\Model\ResourceModel\Category\AggregateCount;
12+
use Magento\Catalog\Model\ResourceModel\Category as ResourceCategory;
13+
use Magento\Framework\DB\Adapter\AdapterInterface;
14+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
15+
use PHPUnit\Framework\MockObject\MockObject;
16+
use PHPUnit\Framework\TestCase;
17+
18+
/**
19+
* Aggregate count model test
20+
*/
21+
class AggregateCountTest extends TestCase
22+
{
23+
24+
/**
25+
* @var AggregateCount
26+
*/
27+
protected $aggregateCount;
28+
29+
/**
30+
* @var ObjectManagerHelper
31+
*/
32+
protected $objectManagerHelper;
33+
34+
/**
35+
* @var Category|MockObject
36+
*/
37+
protected $categoryMock;
38+
39+
/**
40+
* @var ResourceCategory|MockObject
41+
*/
42+
protected $resourceCategoryMock;
43+
44+
/**
45+
* @var AdapterInterface|MockObject
46+
*/
47+
protected $connectionMock;
48+
49+
/**
50+
* {@inheritdoc}
51+
*/
52+
public function setUp(): void
53+
{
54+
$this->categoryMock = $this->createMock(Category::class);
55+
$this->resourceCategoryMock = $this->createMock(ResourceCategory::class);
56+
$this->connectionMock = $this->getMockBuilder(AdapterInterface::class)
57+
->getMockForAbstractClass();
58+
$this->objectManagerHelper = new ObjectManagerHelper($this);
59+
$this->aggregateCount = $this->objectManagerHelper->getObject(AggregateCount::class);
60+
}
61+
62+
/**
63+
* @return void
64+
*/
65+
public function testProcessDelete(): void
66+
{
67+
$parentIds = 3;
68+
$table = 'catalog_category_entity';
69+
70+
$this->categoryMock->expects($this->once())
71+
->method('getResource')
72+
->willReturn($this->resourceCategoryMock);
73+
$this->categoryMock->expects($this->once())
74+
->method('getParentIds')
75+
->willReturn($parentIds);
76+
$this->resourceCategoryMock->expects($this->any())
77+
->method('getEntityTable')
78+
->willReturn($table);
79+
$this->resourceCategoryMock->expects($this->once())
80+
->method('getConnection')
81+
->willReturn($this->connectionMock);
82+
$this->connectionMock->expects($this->once())
83+
->method('update')
84+
->with(
85+
$table,
86+
['children_count' => new \Zend_Db_Expr('children_count - 1')],
87+
['entity_id IN(?)' => $parentIds]
88+
);
89+
$this->aggregateCount->processDelete($this->categoryMock);
90+
}
91+
}

app/code/Magento/Catalog/etc/db_schema.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,11 @@
138138
<index referenceId="CATALOG_PRODUCT_ENTITY_INT_STORE_ID" indexType="btree">
139139
<column name="store_id"/>
140140
</index>
141+
<index referenceId="CATALOG_PRODUCT_ENTITY_INT_ATTRIBUTE_ID_STORE_ID_VALUE" indexType="btree">
142+
<column name="attribute_id"/>
143+
<column name="store_id"/>
144+
<column name="value"/>
145+
</index>
141146
</table>
142147
<table name="catalog_product_entity_text" resource="default" engine="innodb"
143148
comment="Catalog Product Text Attribute Backend Table">

app/code/Magento/Catalog/etc/db_schema_whitelist.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@
6969
},
7070
"index": {
7171
"CATALOG_PRODUCT_ENTITY_INT_ATTRIBUTE_ID": true,
72-
"CATALOG_PRODUCT_ENTITY_INT_STORE_ID": true
72+
"CATALOG_PRODUCT_ENTITY_INT_STORE_ID": true,
73+
"CATALOG_PRODUCT_ENTITY_INT_ATTRIBUTE_ID_STORE_ID_VALUE": true
7374
},
7475
"constraint": {
7576
"PRIMARY": true,

app/code/Magento/Contact/view/frontend/templates/form.phtml

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

7+
// phpcs:disable Magento2.Templates.ThisInTemplate
8+
// phpcs:disable Generic.Files.LineLength.TooLong
9+
710
/** @var \Magento\Contact\Block\ContactForm $block */
811
/** @var \Magento\Contact\ViewModel\UserDataProvider $viewModel */
912

@@ -23,35 +26,35 @@ $viewModel = $block->getViewModel();
2326
<div class="field name required">
2427
<label class="label" for="name"><span><?= $block->escapeHtml(__('Name')) ?></span></label>
2528
<div class="control">
26-
<input name="name"
27-
id="name"
28-
title="<?= $block->escapeHtmlAttr(__('Name')) ?>"
29-
value="<?= $block->escapeHtmlAttr($viewModel->getUserName()) ?>"
30-
class="input-text"
31-
type="text"
29+
<input name="name"
30+
id="name"
31+
title="<?= $block->escapeHtmlAttr(__('Name')) ?>"
32+
value="<?= $block->escapeHtmlAttr($viewModel->getUserName()) ?>"
33+
class="input-text"
34+
type="text"
3235
data-validate="{required:true}"/>
3336
</div>
3437
</div>
3538
<div class="field email required">
3639
<label class="label" for="email"><span><?= $block->escapeHtml(__('Email')) ?></span></label>
3740
<div class="control">
38-
<input name="email"
39-
id="email"
40-
title="<?= $block->escapeHtmlAttr(__('Email')) ?>"
41-
value="<?= $block->escapeHtmlAttr($viewModel->getUserEmail()) ?>"
42-
class="input-text"
43-
type="email"
41+
<input name="email"
42+
id="email"
43+
title="<?= $block->escapeHtmlAttr(__('Email')) ?>"
44+
value="<?= $block->escapeHtmlAttr($viewModel->getUserEmail()) ?>"
45+
class="input-text"
46+
type="email"
4447
data-validate="{required:true, 'validate-email':true}"/>
4548
</div>
4649
</div>
4750
<div class="field telephone">
4851
<label class="label" for="telephone"><span><?= $block->escapeHtml(__('Phone Number')) ?></span></label>
4952
<div class="control">
50-
<input name="telephone"
51-
id="telephone"
52-
title="<?= $block->escapeHtmlAttr(__('Phone Number')) ?>"
53-
value="<?= $block->escapeHtmlAttr($viewModel->getUserTelephone()) ?>"
54-
class="input-text"
53+
<input name="telephone"
54+
id="telephone"
55+
title="<?= $block->escapeHtmlAttr(__('Phone Number')) ?>"
56+
value="<?= $block->escapeHtmlAttr($viewModel->getUserTelephone()) ?>"
57+
class="input-text"
5558
type="tel" />
5659
</div>
5760
</div>
@@ -60,12 +63,12 @@ $viewModel = $block->getViewModel();
6063
<span><?= $block->escapeHtml(__('What’s on your mind?')) ?></span>
6164
</label>
6265
<div class="control">
63-
<textarea name="comment"
64-
id="comment"
65-
title="<?= $block->escapeHtmlAttr(__('What’s on your mind?')) ?>"
66-
class="input-text"
67-
cols="5"
68-
rows="3"
66+
<textarea name="comment"
67+
id="comment"
68+
title="<?= $block->escapeHtmlAttr(__('What’s on your mind?')) ?>"
69+
class="input-text"
70+
cols="5"
71+
rows="3"
6972
data-validate="{required:true}"><?= $block->escapeHtml($viewModel->getUserComment()) ?>
7073
</textarea>
7174
</div>
@@ -81,3 +84,12 @@ $viewModel = $block->getViewModel();
8184
</div>
8285
</div>
8386
</form>
87+
<script type="text/x-magento-init">
88+
{
89+
"*": {
90+
"Magento_Customer/js/block-submit-on-send": {
91+
"formId": "contact-form"
92+
}
93+
}
94+
}
95+
</script>

app/code/Magento/Customer/Block/DataProviders/AddressAttributeData.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function getFrontendLabel(string $attributeCode): string
5252
{
5353
try {
5454
$attribute = $this->addressMetadata->getAttributeMetadata($attributeCode);
55-
$frontendLabel = $attribute->getFrontendLabel();
55+
$frontendLabel = $attribute->getStoreLabel() ?: $attribute->getFrontendLabel();
5656
} catch (NoSuchEntityException $e) {
5757
$frontendLabel = '';
5858
}

app/code/Magento/Customer/view/frontend/templates/form/forgotpassword.phtml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
* @var $block \Magento\Customer\Block\Account\Forgotpassword
77
*/
88

9+
// phpcs:disable Generic.Files.LineLength.TooLong
10+
911
/** @var \Magento\Customer\Block\Account\Forgotpassword $block */
1012
?>
1113
<form class="form password forget"
@@ -32,3 +34,12 @@
3234
</div>
3335
</div>
3436
</form>
37+
<script type="text/x-magento-init">
38+
{
39+
"*": {
40+
"Magento_Customer/js/block-submit-on-send": {
41+
"formId": "form-validate"
42+
}
43+
}
44+
}
45+
</script>

app/code/Magento/Customer/view/frontend/templates/form/login.phtml

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

7+
// phpcs:disable Generic.Files.LineLength.TooLong
8+
79
/** @var \Magento\Customer\Block\Form\Login $block */
810
?>
911
<div class="block block-customer-login">
@@ -22,13 +24,22 @@
2224
<div class="field email required">
2325
<label class="label" for="email"><span><?= $block->escapeHtml(__('Email')) ?></span></label>
2426
<div class="control">
25-
<input name="login[username]" value="<?= $block->escapeHtmlAttr($block->getUsername()) ?>" <?php if ($block->isAutocompleteDisabled()) : ?> autocomplete="off"<?php endif; ?> id="email" type="email" class="input-text" title="<?= $block->escapeHtmlAttr(__('Email')) ?>" data-mage-init='{"mage/trim-input":{}}' data-validate="{required:true, 'validate-email':true}">
27+
<input name="login[username]" value="<?= $block->escapeHtmlAttr($block->getUsername()) ?>"
28+
<?php if ($block->isAutocompleteDisabled()): ?> autocomplete="off"<?php endif; ?>
29+
id="email" type="email" class="input-text"
30+
title="<?= $block->escapeHtmlAttr(__('Email')) ?>"
31+
data-mage-init='{"mage/trim-input":{}}'
32+
data-validate="{required:true, 'validate-email':true}">
2633
</div>
2734
</div>
2835
<div class="field password required">
2936
<label for="pass" class="label"><span><?= $block->escapeHtml(__('Password')) ?></span></label>
3037
<div class="control">
31-
<input name="login[password]" type="password" <?php if ($block->isAutocompleteDisabled()) : ?> autocomplete="off"<?php endif; ?> class="input-text" id="pass" title="<?= $block->escapeHtmlAttr(__('Password')) ?>" data-validate="{required:true}">
38+
<input name="login[password]" type="password"
39+
<?php if ($block->isAutocompleteDisabled()): ?> autocomplete="off"<?php endif; ?>
40+
class="input-text" id="pass"
41+
title="<?= $block->escapeHtmlAttr(__('Password')) ?>"
42+
data-validate="{required:true}">
3243
</div>
3344
</div>
3445
<?= $block->getChildHtml('form_additional_info') ?>
@@ -41,3 +52,12 @@
4152
</div>
4253
</div>
4354

55+
<script type="text/x-magento-init">
56+
{
57+
"*": {
58+
"Magento_Customer/js/block-submit-on-send": {
59+
"formId": "login-form"
60+
}
61+
}
62+
}
63+
</script>

app/code/Magento/Customer/view/frontend/templates/form/register.phtml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -301,13 +301,6 @@ require([
301301
ignore: ignore ? ':hidden:not(' + ignore + ')' : ':hidden'
302302
<?php endif ?>
303303
}).find('input:text').attr('autocomplete', 'off');
304-
dataForm.submit(function () {
305-
$(this).find(':submit').attr('disabled', 'disabled');
306-
});
307-
dataForm.bind("invalid-form.validate", function () {
308-
$(this).find(':submit').prop('disabled', false);
309-
});
310-
311304
});
312305
</script>
313306
<?php if ($block->getShowAddressFields()): ?>
@@ -337,6 +330,11 @@ require([
337330
"passwordStrengthIndicator": {
338331
"formSelector": "form.form-create-account"
339332
}
333+
},
334+
"*": {
335+
"Magento_Customer/js/block-submit-on-send": {
336+
"formId": "form-validate"
337+
}
340338
}
341339
}
342340
</script>

0 commit comments

Comments
 (0)