Skip to content

Commit 9a3cca3

Browse files
committed
Merge remote-tracking branch 'origin/2.4.3-develop' into MC-41780
2 parents 8bfbea0 + 8b3b080 commit 9a3cca3

File tree

295 files changed

+10873
-46670
lines changed

Some content is hidden

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

295 files changed

+10873
-46670
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,5 @@
4343
- [ ] Pull request has a meaningful description of its purpose
4444
- [ ] All commits are accompanied by meaningful commit messages
4545
- [ ] All new or changed code is covered with unit/integration tests (if applicable)
46+
- [ ] README.md files for modified modules are updated and included in the pull request if any [README.md predefined sections](https://github.com/magento/devdocs/wiki/Magento-module-README.md) require an update
4647
- [ ] All automated tests passed successfully (all builds are green)

app/code/Magento/Backend/Block/Store/Switcher.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
67

78
namespace Magento\Backend\Block\Store;
89

@@ -114,7 +115,8 @@ protected function _construct()
114115
{
115116
parent::_construct();
116117

117-
$this->setUseConfirm(true);
118+
$this->setUseConfirm($this->hasData('use_confirm') ? (bool)$this->getData('use_confirm') : true);
119+
118120
$this->setUseAjax(true);
119121

120122
$this->setShowManageStoresLink(0);

app/code/Magento/Backend/view/adminhtml/templates/media/uploader.phtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* See COPYING.txt for license details.
55
*/
66

7+
// phpcs:disable PHPCompatibility.Miscellaneous.RemovedAlternativePHPTags.MaybeASPOpenTagFound
78
/** @var $block \Magento\Backend\Block\Media\Uploader */
89
?>
910

app/code/Magento/Backend/view/adminhtml/templates/store/switcher.phtml

Lines changed: 117 additions & 207 deletions
Large diffs are not rendered by default.

app/code/Magento/Backend/view/adminhtml/templates/system/search.phtml

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

7-
/** @var $block \Magento\Backend\Block\GlobalSearch */
7+
// phpcs:disable PHPCompatibility.Miscellaneous.RemovedAlternativePHPTags.MaybeASPOpenTagFound
8+
9+
use Magento\Backend\Block\GlobalSearch;
10+
use Magento\Framework\Json\Helper\Data;
11+
12+
/** @var $block GlobalSearch */
13+
/** @var Data $helper */
14+
$helper = $this->helper(Data::class);
15+
816
?>
917
<div class="search-global" data-mage-init='{"globalSearch": {}}'>
1018
<form action="#" id="form-search">
@@ -15,9 +23,7 @@
1523
class="search-global-input"
1624
id="search-global"
1725
name="query"
18-
<?php //phpcs:disable ?>
19-
data-mage-init='<?= /* @noEscape */ $this->helper(\Magento\Framework\Json\Helper\Data::class)->jsonEncode($block->getWidgetInitOptions()) ?>'>
20-
<?php //phpcs:enable ?>
26+
data-mage-init='<?= /* @noEscape */ $helper->jsonEncode($block->getWidgetInitOptions()) ?>'>
2127
<button
2228
type="submit"
2329
class="search-global-action"
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
define([
7+
'jquery'
8+
], function ($) {
9+
'use strict';
10+
11+
/**
12+
* @param {Object} storeSwitchConfig
13+
*/
14+
return function (storeSwitchConfig) {
15+
var scopeSwitcherHandler;
16+
17+
(function () {
18+
var storesList = $('[data-role=stores-list]');
19+
20+
storesList.on('click', '[data-value]', function (event) {
21+
var val = $(event.target).data('value'),
22+
role = $(event.target).data('role'),
23+
switcher = $('[data-role=' + role + ']');
24+
25+
event.preventDefault();
26+
27+
if (!switcher.val() || val !== switcher.val()) {
28+
29+
/* Set the value & trigger event */
30+
switcher.val(val).trigger('change');
31+
}
32+
});
33+
})($);
34+
35+
/**
36+
* Switch store scope
37+
*
38+
* @param {Object} obj
39+
* @return void
40+
*/
41+
function switchScope(obj) {
42+
var switcher = $(obj),
43+
scopeId = switcher.val(),
44+
scopeParams = '',
45+
switcherParams = {};
46+
47+
if (scopeId) {
48+
scopeParams = switcher.data('param') + '/' + scopeId + '/';
49+
}
50+
51+
if (obj.switchParams) {
52+
scopeParams += obj.switchParams;
53+
}
54+
55+
/**
56+
* Reload function for switcher
57+
*/
58+
function reload() {
59+
var url;
60+
61+
if (!storeSwitchConfig.isUsingIframe) {
62+
63+
if (storeSwitchConfig.switchUrl && storeSwitchConfig.switchUrl.length > 0) {
64+
url = storeSwitchConfig.switchUrl + scopeParams;
65+
66+
/* eslint-disable no-undef */
67+
setLocation(url);
68+
}
69+
70+
} else {
71+
$('#preview_selected_store').val(scopeId);
72+
$('#preview_form').submit();
73+
74+
$('.store-switcher .dropdown-menu li a').each(function () {
75+
var $this = $(this);
76+
77+
if ($this.data('role') === 'store-view-id' && $this.data('value') === scopeId) {
78+
$('#store-change-button').html($this.text());
79+
}
80+
});
81+
82+
$('#store-change-button').click();
83+
}
84+
}
85+
86+
if (typeof scopeSwitcherHandler !== 'undefined') {
87+
switcherParams = {
88+
scopeId: scopeId,
89+
scopeParams: scopeParams,
90+
useConfirm: storeSwitchConfig.useConfirm
91+
};
92+
93+
scopeSwitcherHandler(switcherParams);
94+
} else if (storeSwitchConfig.useConfirm) {
95+
require([
96+
'Magento_Ui/js/modal/confirm',
97+
'mage/translate'
98+
], function (confirm, $t) {
99+
confirm({
100+
content: $t('Please confirm scope switching. All data that hasn\'t been saved will be lost.'),
101+
actions: {
102+
103+
/**
104+
* Confirm action
105+
*/
106+
confirm: function () {
107+
reload();
108+
},
109+
110+
/**
111+
* Cancel action
112+
*/
113+
cancel: function () {
114+
obj.value = storeSwitchConfig.storeId ? storeSwitchConfig.storeId : '';
115+
}
116+
}
117+
});
118+
});
119+
} else {
120+
reload();
121+
}
122+
}
123+
124+
window.scopeSwitcherHandler = scopeSwitcherHandler;
125+
window.switchScope = switchScope;
126+
};
127+
});

app/code/Magento/Bundle/Model/Product/SaveHandler.php

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88
namespace Magento\Bundle\Model\Product;
99

1010
use Magento\Bundle\Api\Data\OptionInterface;
11+
use Magento\Bundle\Api\ProductLinkManagementInterface;
12+
use Magento\Bundle\Api\ProductOptionRepositoryInterface as OptionRepository;
1113
use Magento\Bundle\Model\Option\SaveAction;
14+
use Magento\Bundle\Model\ProductRelationsProcessorComposite;
1215
use Magento\Catalog\Api\Data\ProductInterface;
13-
use Magento\Bundle\Api\ProductOptionRepositoryInterface as OptionRepository;
14-
use Magento\Bundle\Api\ProductLinkManagementInterface;
1516
use Magento\Framework\App\ObjectManager;
1617
use Magento\Framework\EntityManager\MetadataPool;
1718
use Magento\Framework\EntityManager\Operation\ExtensionInterface;
@@ -48,26 +49,35 @@ class SaveHandler implements ExtensionInterface
4849
*/
4950
private $checkOptionLinkIfExist;
5051

52+
/**
53+
* @var ProductRelationsProcessorComposite
54+
*/
55+
private $productRelationsProcessorComposite;
56+
5157
/**
5258
* @param OptionRepository $optionRepository
5359
* @param ProductLinkManagementInterface $productLinkManagement
5460
* @param SaveAction $optionSave
5561
* @param MetadataPool $metadataPool
5662
* @param CheckOptionLinkIfExist|null $checkOptionLinkIfExist
63+
* @param ProductRelationsProcessorComposite|null $productRelationsProcessorComposite
5764
*/
5865
public function __construct(
5966
OptionRepository $optionRepository,
6067
ProductLinkManagementInterface $productLinkManagement,
6168
SaveAction $optionSave,
6269
MetadataPool $metadataPool,
63-
?CheckOptionLinkIfExist $checkOptionLinkIfExist = null
70+
?CheckOptionLinkIfExist $checkOptionLinkIfExist = null,
71+
?ProductRelationsProcessorComposite $productRelationsProcessorComposite = null
6472
) {
6573
$this->optionRepository = $optionRepository;
6674
$this->productLinkManagement = $productLinkManagement;
6775
$this->optionSave = $optionSave;
6876
$this->metadataPool = $metadataPool;
69-
$this->checkOptionLinkIfExist = $checkOptionLinkIfExist ??
70-
ObjectManager::getInstance()->get(CheckOptionLinkIfExist::class);
77+
$this->checkOptionLinkIfExist = $checkOptionLinkIfExist
78+
?? ObjectManager::getInstance()->get(CheckOptionLinkIfExist::class);
79+
$this->productRelationsProcessorComposite = $productRelationsProcessorComposite
80+
?? ObjectManager::getInstance()->get(ProductRelationsProcessorComposite::class);
7181
}
7282

7383
/**
@@ -107,6 +117,12 @@ public function execute($entity, $arguments = [])
107117
$entity->setCopyFromView(false);
108118
}
109119

120+
$this->productRelationsProcessorComposite->process(
121+
$entity,
122+
$existingBundleProductOptions,
123+
$bundleProductOptions
124+
);
125+
110126
return $entity;
111127
}
112128

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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\Bundle\Model;
9+
10+
use Magento\Catalog\Api\Data\ProductInterface;
11+
12+
/**
13+
* Composite processor to handle bundle product relations.
14+
*/
15+
class ProductRelationsProcessorComposite implements ProductRelationsProcessorInterface
16+
{
17+
/**
18+
* @var ProductRelationsProcessorInterface[]
19+
*/
20+
private $processors;
21+
22+
/**
23+
* @param ProductRelationsProcessorInterface[] $processors
24+
*/
25+
public function __construct(array $processors = [])
26+
{
27+
foreach ($processors as $processor) {
28+
if (!$processor instanceof ProductRelationsProcessorInterface) {
29+
throw new \InvalidArgumentException(
30+
__('Product relations processor must implement %1.', ProductRelationsProcessorInterface::class)
31+
);
32+
}
33+
}
34+
35+
$this->processors = $processors;
36+
}
37+
38+
/**
39+
* @inheritDoc
40+
*/
41+
public function process(
42+
ProductInterface $product,
43+
array $existingProductOptions,
44+
array $expectedProductOptions
45+
): void {
46+
foreach ($this->processors as $processor) {
47+
$processor->process($product, $existingProductOptions, $expectedProductOptions);
48+
}
49+
}
50+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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\Bundle\Model;
9+
10+
/**
11+
* Processor to handle bundle product relations.
12+
*/
13+
interface ProductRelationsProcessorInterface
14+
{
15+
/**
16+
* Process bundle product relations.
17+
*
18+
* @param \Magento\Catalog\Api\Data\ProductInterface $product
19+
* @param array $existingProductOptions
20+
* @param array $expectedProductOptions
21+
* @return void
22+
*/
23+
public function process(
24+
\Magento\Catalog\Api\Data\ProductInterface $product,
25+
array $existingProductOptions,
26+
array $expectedProductOptions
27+
): void;
28+
}

0 commit comments

Comments
 (0)