Skip to content

Commit 01393ce

Browse files
authored
Merge pull request #2895 from magento-mpi/mpi-PR-2307
[MPI]-fix-2307
2 parents e89e9bf + 5aaed2e commit 01393ce

File tree

33 files changed

+746
-931
lines changed

33 files changed

+746
-931
lines changed

app/code/Magento/Braintree/view/adminhtml/web/js/braintree.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ define([
2424
scriptLoaded: false,
2525
braintree: null,
2626
selectedCardType: null,
27+
checkout: null,
2728
imports: {
2829
onActiveChange: 'active'
2930
}
@@ -147,14 +148,21 @@ define([
147148

148149
this.disableEventListeners();
149150

151+
if (self.checkout) {
152+
self.checkout.teardown(function () {
153+
self.checkout = null;
154+
});
155+
}
156+
150157
self.braintree.setup(self.clientToken, 'custom', {
151158
id: self.selector,
152159
hostedFields: self.getHostedFields(),
153160

154161
/**
155162
* Triggered when sdk was loaded
156163
*/
157-
onReady: function () {
164+
onReady: function (checkout) {
165+
self.checkout = checkout;
158166
$('body').trigger('processStop');
159167
self.enableEventListeners();
160168
},

app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/WebsitesTest.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,11 @@ protected function setUp()
9090
->disableOriginalConstructor()
9191
->getMock();
9292
$this->websiteRepositoryMock = $this->getMockBuilder(\Magento\Store\Api\WebsiteRepositoryInterface::class)
93-
->setMethods(['getList', 'getDefault'])
93+
->setMethods(['getDefault'])
9494
->getMockForAbstractClass();
9595
$this->websiteRepositoryMock->expects($this->any())
9696
->method('getDefault')
9797
->willReturn($this->websiteMock);
98-
$this->websiteRepositoryMock->expects($this->any())
99-
->method('getList')
100-
->willReturn([$this->websiteMock, $this->secondWebsiteMock]);
10198
$this->groupRepositoryMock = $this->getMockBuilder(\Magento\Store\Api\GroupRepositoryInterface::class)
10299
->setMethods(['getList'])
103100
->getMockForAbstractClass();
@@ -111,8 +108,10 @@ protected function setUp()
111108
->method('getWebsiteIds')
112109
->willReturn($this->assignedWebsites);
113110
$this->storeManagerMock = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class)
114-
->setMethods(['isSingleStoreMode'])
111+
->setMethods(['isSingleStoreMode', 'getWebsites'])
115112
->getMockForAbstractClass();
113+
$this->storeManagerMock->method('getWebsites')
114+
->willReturn([$this->websiteMock, $this->secondWebsiteMock]);
116115
$this->storeManagerMock->expects($this->any())
117116
->method('isSingleStoreMode')
118117
->willReturn(false);

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Websites.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,11 @@ protected function getFieldsForFieldset()
175175
$label = __('Websites');
176176

177177
$defaultWebsiteId = $this->websiteRepository->getDefault()->getId();
178+
$isOnlyOneWebsiteAvailable = count($websitesList) === 1;
178179
foreach ($websitesList as $website) {
179180
$isChecked = in_array($website['id'], $websiteIds)
180-
|| ($defaultWebsiteId == $website['id'] && $isNewProduct);
181+
|| ($defaultWebsiteId == $website['id'] && $isNewProduct)
182+
|| $isOnlyOneWebsiteAvailable;
181183
$children[$website['id']] = [
182184
'arguments' => [
183185
'data' => [
@@ -397,8 +399,9 @@ protected function getWebsitesList()
397399
$this->websitesList = [];
398400
$groupList = $this->groupRepository->getList();
399401
$storesList = $this->storeRepository->getList();
402+
$websiteList = $this->storeManager->getWebsites(true);
400403

401-
foreach ($this->websiteRepository->getList() as $website) {
404+
foreach ($websiteList as $website) {
402405
$websiteId = $website->getId();
403406
if (!$websiteId) {
404407
continue;

app/code/Magento/Catalog/view/frontend/templates/product/view/gallery.phtml

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

7-
// @codingStandardsIgnoreFile
8-
97
/**
108
* Product media data template
119
*
@@ -15,19 +13,19 @@
1513
<div class="gallery-placeholder _block-content-loading" data-gallery-role="gallery-placeholder">
1614
<div data-role="loader" class="loading-mask">
1715
<div class="loader">
18-
<img src="<?= /* @escapeNotVerified */ $block->getViewFileUrl('images/loader-1.gif') ?>"
19-
alt="<?= /* @escapeNotVerified */ __('Loading...') ?>">
16+
<img src="<?= $block->escapeUrl($block->getViewFileUrl('images/loader-1.gif')) ?>"
17+
alt="<?= $block->escapeHtml(__('Loading...')) ?>">
2018
</div>
2119
</div>
2220
</div>
2321
<!--Fix for jumping content. Loader must be the same size as gallery.-->
2422
<script>
2523
var config = {
26-
"width": <?= /* @escapeNotVerified */ $block->getImageAttribute('product_page_image_medium', 'width') ?>,
27-
"thumbheight": <?php /* @escapeNotVerified */ echo $block->getImageAttribute('product_page_image_small', 'height')
28-
?: $block->getImageAttribute('product_page_image_small', 'width'); ?>,
29-
"navtype": "<?= /* @escapeNotVerified */ $block->getVar("gallery/navtype") ?>",
30-
"height": <?= /* @escapeNotVerified */ $block->getImageAttribute('product_page_image_medium', 'height') ?>
24+
"width": <?= $block->escapeHtml($block->getImageAttribute('product_page_image_medium', 'width')) ?>,
25+
"thumbheight": <?= $block->escapeHtml($block->getImageAttribute('product_page_image_small', 'height')
26+
?: $block->getImageAttribute('product_page_image_small', 'width')); ?>,
27+
"navtype": "<?= $block->escapeHtml($block->getVar("gallery/navtype")) ?>",
28+
"height": <?= $block->escapeHtml($block->getImageAttribute('product_page_image_medium', 'height')) ?>
3129
},
3230
thumbBarHeight = 0,
3331
loader = document.querySelectorAll('[data-gallery-role="gallery-placeholder"] [data-role="loader"]')[0];
@@ -43,50 +41,82 @@
4341
"[data-gallery-role=gallery-placeholder]": {
4442
"mage/gallery/gallery": {
4543
"mixins":["magnifier/magnify"],
46-
"magnifierOpts": <?= /* @escapeNotVerified */ $block->getMagnifier() ?>,
47-
"data": <?= /* @escapeNotVerified */ $block->getGalleryImagesJson() ?>,
44+
"magnifierOpts": <?= /* @noEscape */ $block->getMagnifier() ?>,
45+
"data": <?= /* @noEscape */ $block->getGalleryImagesJson() ?>,
4846
"options": {
49-
"nav": "<?= /* @escapeNotVerified */ $block->getVar("gallery/nav") ?>",
50-
"loop": <?= /* @escapeNotVerified */ $block->getVar("gallery/loop") ? 'true' : 'false' ?>,
51-
"keyboard": <?= /* @escapeNotVerified */ $block->getVar("gallery/keyboard") ? 'true' : 'false' ?>,
52-
"arrows": <?= /* @escapeNotVerified */ $block->getVar("gallery/arrows") ? 'true' : 'false' ?>,
53-
"allowfullscreen": <?= /* @escapeNotVerified */ $block->getVar("gallery/allowfullscreen") ? 'true' : 'false' ?>,
54-
"showCaption": <?= /* @escapeNotVerified */ $block->getVar("gallery/caption") ? 'true' : 'false' ?>,
55-
"width": "<?= /* @escapeNotVerified */ $block->getImageAttribute('product_page_image_medium', 'width') ?>",
56-
"thumbwidth": "<?= /* @escapeNotVerified */ $block->getImageAttribute('product_page_image_small', 'width') ?>",
57-
<?php if ($block->getImageAttribute('product_page_image_small', 'height') || $block->getImageAttribute('product_page_image_small', 'width')): ?>
58-
"thumbheight": <?php /* @escapeNotVerified */ echo $block->getImageAttribute('product_page_image_small', 'height')
59-
?: $block->getImageAttribute('product_page_image_small', 'width'); ?>,
47+
"nav": "<?= $block->escapeHtml($block->getVar("gallery/nav")) ?>",
48+
<?php if (($block->getVar("gallery/loop"))) : ?>
49+
"loop": <?= $block->escapeHtml($block->getVar("gallery/loop")) ?>,
50+
<?php endif; ?>
51+
<?php if (($block->getVar("gallery/keyboard"))) : ?>
52+
"keyboard": <?= $block->escapeHtml($block->getVar("gallery/keyboard")) ?>,
53+
<?php endif; ?>
54+
<?php if (($block->getVar("gallery/arrows"))) : ?>
55+
"arrows": <?= $block->escapeHtml($block->getVar("gallery/arrows")) ?>,
56+
<?php endif; ?>
57+
<?php if (($block->getVar("gallery/allowfullscreen"))) : ?>
58+
"allowfullscreen": <?= $block->escapeHtml($block->getVar("gallery/allowfullscreen")) ?>,
59+
<?php endif; ?>
60+
<?php if (is_bool($block->getVar("gallery/caption"))) : ?>
61+
"showCaption": <?= /* @noEscape */ $block->getVar("gallery/caption") ? 'true' : 'false'; ?>,
62+
<?php endif; ?>
63+
<?php
64+
$imgWidth = $block->getImageAttribute('product_page_image_medium', 'width');
65+
$thumbWidth = $block->getImageAttribute('product_page_image_small', 'width');
66+
?>
67+
"width": "<?= $block->escapeHtml($imgWidth) ?>",
68+
"thumbwidth": "<?= $block->escapeHtml($thumbWidth) ?>",
69+
<?php
70+
$thumbHeight = $block->getImageAttribute('product_page_image_small', 'height')
71+
?: $block->getImageAttribute('product_page_image_small', 'width');
72+
?>
73+
<?php if ($thumbHeight) : ?>
74+
"thumbheight": <?= $block->escapeHtml($thumbHeight); ?>,
6075
<?php endif; ?>
61-
<?php if (($block->getVar("gallery/thumbmargin"))): ?>
62-
"thumbmargin": <?= /* @noEscape */ (int)$block->getVar("gallery/thumbmargin"); ?>,
76+
<?php if (($block->getVar("gallery/thumbmargin"))) : ?>
77+
"thumbmargin": <?= (int)$block->getVar("gallery/thumbmargin"); ?>,
6378
<?php endif; ?>
64-
<?php if ($block->getImageAttribute('product_page_image_medium', 'height') || $block->getImageAttribute('product_page_image_medium', 'width')): ?>
65-
"height": <?php /* @escapeNotVerified */ echo $block->getImageAttribute('product_page_image_medium', 'height')
66-
?: $block->getImageAttribute('product_page_image_medium', 'width'); ?>,
79+
<?php
80+
$imgHeight = $block->getImageAttribute('product_page_image_medium', 'height')
81+
?: $block->getImageAttribute('product_page_image_medium', 'width')
82+
?>
83+
<?php if ($imgHeight) : ?>
84+
"height": <?= $block->escapeHtml($imgHeight); ?>,
6785
<?php endif; ?>
68-
<?php if ($block->getVar("gallery/transition/duration")): ?>
69-
"transitionduration": <?= /* @escapeNotVerified */ $block->getVar("gallery/transition/duration") ?>,
86+
<?php if ($block->getVar("gallery/transition/duration")) : ?>
87+
"transitionduration": <?= $block->escapeHtml($block->getVar("gallery/transition/duration")) ?>,
7088
<?php endif; ?>
71-
"transition": "<?= /* @escapeNotVerified */ $block->getVar("gallery/transition/effect") ?>",
72-
"navarrows": <?= /* @escapeNotVerified */ $block->getVar("gallery/navarrows") ? 'true' : 'false' ?>,
73-
"navtype": "<?= /* @escapeNotVerified */ $block->getVar("gallery/navtype") ?>",
74-
"navdir": "<?= /* @escapeNotVerified */ $block->getVar("gallery/navdir") ?>"
89+
"transition": "<?= $block->escapeHtml($block->getVar("gallery/transition/effect")) ?>",
90+
<?php if (($block->getVar("gallery/navarrows"))) : ?>
91+
"navarrows": <?= $block->escapeHtml($block->getVar("gallery/navarrows")) ?>,
92+
<?php endif; ?>
93+
"navtype": "<?= $block->escapeHtml($block->getVar("gallery/navtype")) ?>",
94+
"navdir": "<?= $block->escapeHtml($block->getVar("gallery/navdir")) ?>"
7595
},
7696
"fullscreen": {
77-
"nav": "<?= /* @escapeNotVerified */ $block->getVar("gallery/fullscreen/nav") ?>",
78-
"loop": <?= /* @escapeNotVerified */ $block->getVar("gallery/fullscreen/loop") ? 'true' : 'false' ?>,
79-
"navdir": "<?= /* @escapeNotVerified */ $block->getVar("gallery/fullscreen/navdir") ?>",
80-
"navarrows": <?= /* @escapeNotVerified */ $block->getVar("gallery/fullscreen/navarrows") ? 'true' : 'false' ?>,
81-
"navtype": "<?= /* @escapeNotVerified */ $block->getVar("gallery/fullscreen/navtype") ?>",
82-
"arrows": <?= /* @escapeNotVerified */ $block->getVar("gallery/fullscreen/arrows") ? 'true' : 'false' ?>,
83-
"showCaption": <?= /* @escapeNotVerified */ $block->getVar("gallery/fullscreen/caption") ? 'true' : 'false' ?>,
84-
<?php if ($block->getVar("gallery/fullscreen/transition/duration")): ?>
85-
"transitionduration": <?= /* @escapeNotVerified */ $block->getVar("gallery/fullscreen/transition/duration") ?>,
97+
"nav": "<?= $block->escapeHtml($block->getVar("gallery/fullscreen/nav")) ?>",
98+
<?php if ($block->getVar("gallery/fullscreen/loop")) : ?>
99+
"loop": <?= $block->escapeHtml($block->getVar("gallery/fullscreen/loop")) ?>,
100+
<?php endif; ?>
101+
"navdir": "<?= $block->escapeHtml($block->getVar("gallery/fullscreen/navdir")) ?>",
102+
<?php if ($block->getVar("gallery/transition/navarrows")) : ?>
103+
"navarrows": <?= $block->escapeHtml($block->getVar("gallery/fullscreen/navarrows")) ?>,
104+
<?php endif; ?>
105+
"navtype": "<?= $block->escapeHtml($block->getVar("gallery/fullscreen/navtype")) ?>",
106+
<?php if ($block->getVar("gallery/fullscreen/arrows")) : ?>
107+
"arrows": <?= $block->escapeHtml($block->getVar("gallery/fullscreen/arrows")) ?>,
108+
<?php endif; ?>
109+
<?php if (is_bool($block->getVar("gallery/fullscreen/caption"))) : ?>
110+
<?php $showCaption = $block->getVar("gallery/fullscreen/caption") ? 'true' : 'false'; ?>
111+
"showCaption": <?= /* @noEscape */ $showCaption ?>,
112+
<?php endif; ?>
113+
<?php if ($block->getVar("gallery/fullscreen/transition/duration")) : ?>
114+
"transitionduration": <?=
115+
$block->escapeHtml($block->getVar("gallery/fullscreen/transition/duration")) ?>,
86116
<?php endif; ?>
87-
"transition": "<?= /* @escapeNotVerified */ $block->getVar("gallery/fullscreen/transition/effect") ?>"
117+
"transition": "<?= $block->escapeHtml($block->getVar("gallery/fullscreen/transition/effect")) ?>"
88118
},
89-
"breakpoints": <?= /* @escapeNotVerified */ $block->getBreakpoints() ?>
119+
"breakpoints": <?= /* @noEscape */ $block->getBreakpoints() ?>
90120
}
91121
}
92122
}

app/code/Magento/CatalogInventory/Model/Stock/Status.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ public function getQty()
106106
/**
107107
* @return int
108108
*/
109-
public function getStockStatus()
109+
public function getStockStatus(): int
110110
{
111-
return $this->getData(self::KEY_STOCK_STATUS);
111+
return (int)$this->getData(self::KEY_STOCK_STATUS);
112112
}
113113

114114
//@codeCoverageIgnoreEnd

0 commit comments

Comments
 (0)