Skip to content

Commit 975b90b

Browse files
🔃 [EngCom] Public Pull Requests - 2.2-develop
Accepted Public Pull Requests: - #12929: Issues #10559 - Extend swatch using mixins (M2.2) (by @srenon) - #14121: [Backport] Open link "Report an Issue" in a new tab (by @sidolov) - magento-engcom/magento2ce#1453: [2.2] Add a CodeTriage badge to magento/magento2 (by @ishakhsuvarov) - #14105: #13820: IE11 minicart not updating on configurable pr� (by @Frodigo) - #13989: Act better on existing input focus instead of removing it (by @krzksz) - #14083: Fix product attribute ordering when more than 10 attributes. (by @RandeKnight) - #14029: Fix $useCache for container child blocks (by @tdgroot) - #14062: Typo in SSL port number (by @jasperzeinstra) - #14042: Improve array output format for etc.php and config.php (by @avstudnitz) - #13894: Fix cache issue for currencies with no symbol (by @evgk) - #13884: #5463 - Use specified hashing algo in \Magento\Framework\Encryption\Encryptor::getHash (by @k4emic) - magento-engcom/magento2ce#1258: #13231: Default State or Province is not pre-selected in the Estimate Shipping and Tax (by @serhii-balko) Fixed GitHub Issues: - #10559: Extending swatch functionality using javascript mixins does not work in Safari and MS Edge (reported by @srenon) has been fixed in #12929 by @srenon in 2.2-develop branch Related commits: 1. 1350c77 2. 33261e0 3. 4fca69d 4. 97779a6 5. 494c9c0 6. 20b9575 7. 089b468 8. ca471e4 9. c84087e 10. ec51bd2 11. d4fa8a5 - #14010: Why Report Bugs link not open in new tab? (reported by @webshouters) has been fixed in #14121 by @sidolov in 2.2-develop branch Related commits: 1. 8cfffc1 - #13820: IE11 minicart not updating on configurable product page (ES6) (reported by @Pumppa) has been fixed in #14105 by @Frodigo in 2.2-develop branch Related commits: 1. 2235f3e - #13988: Mini search field looses focus after its JavaScript is initialized (reported by @krzksz) has been fixed in #13989 by @krzksz in 2.2-develop branch Related commits: 1. 9eb3c6f - #5463: The ability to store passwords using different hashing algorithms is limited (reported by @maderlock) has been fixed in #13884 by @k4emic in 2.2-develop branch Related commits: 1. adab3e5 - #13231: Default State or Province is not pre-selected in the Estimate Shipping and Tax (reported by @hanxiangwu) has been fixed in magento-engcom/magento2ce#1258 by @serhii-balko in 2.2-develop branch Related commits: 1. 0cabe58 2. 0ad6208 3. e26c22f 4. 7b0a489 5. 35fb319 6. 5837d36 7. 4d50066 8. 04e573a
2 parents cb0954a + b1df309 commit 975b90b

File tree

22 files changed

+493
-196
lines changed

22 files changed

+493
-196
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
[![Build Status](https://travis-ci.org/magento/magento2.svg?branch=develop)](https://travis-ci.org/magento/magento2)
1+
[![Build Status](https://travis-ci.org/magento/magento2.svg?branch=2.2-develop)](https://travis-ci.org/magento/magento2)
2+
[![Open Source Helpers](https://www.codetriage.com/magento/magento2/badges/users.svg)](https://www.codetriage.com/magento/magento2)
23
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/magento/magento2?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
34
[![Crowdin](https://d322cqt584bo4o.cloudfront.net/magento-2/localized.png)](https://crowdin.com/project/magento-2)
45
<h2>Welcome</h2>

app/code/Magento/Backend/view/adminhtml/templates/page/report.phtml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,7 @@
88

99
?>
1010
<?php if ($block->getBugreportUrl()): ?>
11-
<a class="link-report" href="<?= /* @escapeNotVerified */ $block->getBugreportUrl() ?>" id="footer_bug_tracking"><?= /* @escapeNotVerified */ __('Report an Issue') ?></a>
11+
<a class="link-report" href="<?= /* @escapeNotVerified */ $block->getBugreportUrl() ?>" id="footer_bug_tracking" target="_blank">
12+
<?= /* @escapeNotVerified */ __('Report an Issue') ?>
13+
</a>
1214
<?php endif; ?>

app/code/Magento/Catalog/Pricing/Render/FinalPriceBox.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ protected function wrapResult($html)
115115
{
116116
return '<div class="price-box ' . $this->getData('css_classes') . '" ' .
117117
'data-role="priceBox" ' .
118-
'data-product-id="' . $this->getSaleableItem()->getId() . '"' .
118+
'data-product-id="' . $this->getSaleableItem()->getId() . '" ' .
119+
'data-price-box="product-id-' . $this->getSaleableItem()->getId() . '"' .
119120
'>' . $html . '</div>';
120121
}
121122

app/code/Magento/Catalog/Test/Unit/Pricing/Render/FinalPriceBoxTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,8 @@ public function testRenderMsrpEnabled()
246246

247247
//assert price wrapper
248248
$this->assertEquals(
249-
'<div class="price-box price-final_price" data-role="priceBox" data-product-id="">test</div>',
249+
'<div class="price-box price-final_price" data-role="priceBox" data-product-id="" ' .
250+
'data-price-box="product-id-">test</div>',
250251
$result
251252
);
252253
}

app/code/Magento/Checkout/view/frontend/web/js/model/new-customer-address.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,26 @@ define([
1717
*/
1818
return function (addressData) {
1919
var identifier = Date.now(),
20+
countryId,
2021
regionId;
2122

22-
if (addressData.region && addressData.region['region_id']) {
23-
regionId = addressData.region['region_id'];
24-
} else if (addressData['country_id'] && addressData['country_id'] == window.checkoutConfig.defaultCountryId) { //eslint-disable-line
25-
regionId = window.checkoutConfig.defaultRegionId || undefined;
23+
countryId = addressData['country_id'] || addressData.countryId;
24+
25+
if (countryId) {
26+
if (addressData.region && addressData.region['region_id']) {
27+
regionId = addressData.region['region_id'];
28+
} else if (countryId === window.checkoutConfig.defaultCountryId) {
29+
regionId = window.checkoutConfig.defaultRegionId;
30+
}
31+
} else {
32+
countryId = window.checkoutConfig.defaultCountryId;
33+
regionId = window.checkoutConfig.defaultRegionId;
2634
}
2735

2836
return {
2937
email: addressData.email,
30-
countryId: addressData['country_id'] || addressData.countryId || window.checkoutConfig.defaultCountryId,
31-
regionId: regionId || addressData.regionId,
38+
countryId: countryId,
39+
regionId: regionId,
3240
regionCode: addressData.region ? addressData.region['region_code'] : null,
3341
region: addressData.region ? addressData.region.region : null,
3442
customerId: addressData['customer_id'] || addressData.customerId,

app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ class Configurable extends \Magento\Catalog\Block\Product\View\AbstractView
7474
*/
7575
private $customerSession;
7676

77+
/**
78+
* @var \Magento\ConfigurableProduct\Model\Product\Type\Configurable\Variations\Prices
79+
*/
80+
private $variationPrices;
81+
7782
/**
7883
* @param \Magento\Catalog\Block\Product\Context $context
7984
* @param \Magento\Framework\Stdlib\ArrayUtils $arrayUtils
@@ -86,6 +91,7 @@ class Configurable extends \Magento\Catalog\Block\Product\View\AbstractView
8691
* @param array $data
8792
* @param Format|null $localeFormat
8893
* @param Session|null $customerSession
94+
* @param \Magento\ConfigurableProduct\Model\Product\Type\Configurable\Variations\Prices|null $variationPrices
8995
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
9096
*/
9197
public function __construct(
@@ -99,7 +105,8 @@ public function __construct(
99105
ConfigurableAttributeData $configurableAttributeData,
100106
array $data = [],
101107
Format $localeFormat = null,
102-
Session $customerSession = null
108+
Session $customerSession = null,
109+
\Magento\ConfigurableProduct\Model\Product\Type\Configurable\Variations\Prices $variationPrices = null
103110
) {
104111
$this->priceCurrency = $priceCurrency;
105112
$this->helper = $helper;
@@ -109,6 +116,9 @@ public function __construct(
109116
$this->configurableAttributeData = $configurableAttributeData;
110117
$this->localeFormat = $localeFormat ?: ObjectManager::getInstance()->get(Format::class);
111118
$this->customerSession = $customerSession ?: ObjectManager::getInstance()->get(Session::class);
119+
$this->variationPrices = $variationPrices ?: ObjectManager::getInstance()->get(
120+
\Magento\ConfigurableProduct\Model\Product\Type\Configurable\Variations\Prices::class
121+
);
112122

113123
parent::__construct(
114124
$context,
@@ -126,7 +136,7 @@ public function __construct(
126136
public function getCacheKeyInfo()
127137
{
128138
$parentData = parent::getCacheKeyInfo();
129-
$parentData[] = $this->priceCurrency->getCurrencySymbol();
139+
$parentData[] = $this->priceCurrency->getCurrency()->getCode();
130140
$parentData[] = $this->customerSession->getCustomerGroupId();
131141
return $parentData;
132142
}
@@ -211,9 +221,6 @@ public function getJsonConfig()
211221
$store = $this->getCurrentStore();
212222
$currentProduct = $this->getProduct();
213223

214-
$regularPrice = $currentProduct->getPriceInfo()->getPrice('regular_price');
215-
$finalPrice = $currentProduct->getPriceInfo()->getPrice('final_price');
216-
217224
$options = $this->helper->getOptions($currentProduct, $this->getAllowProducts());
218225
$attributesData = $this->configurableAttributeData->getAttributesData($currentProduct, $options);
219226

@@ -223,17 +230,7 @@ public function getJsonConfig()
223230
'currencyFormat' => $store->getCurrentCurrency()->getOutputFormat(),
224231
'optionPrices' => $this->getOptionPrices(),
225232
'priceFormat' => $this->localeFormat->getPriceFormat(),
226-
'prices' => [
227-
'oldPrice' => [
228-
'amount' => $this->localeFormat->getNumber($regularPrice->getAmount()->getValue()),
229-
],
230-
'basePrice' => [
231-
'amount' => $this->localeFormat->getNumber($finalPrice->getAmount()->getBaseAmount()),
232-
],
233-
'finalPrice' => [
234-
'amount' => $this->localeFormat->getNumber($finalPrice->getAmount()->getValue()),
235-
],
236-
],
233+
'prices' => $this->variationPrices->getFormattedPrices($this->getProduct()->getPriceInfo()),
237234
'productId' => $currentProduct->getId(),
238235
'chooseText' => __('Choose an Option...'),
239236
'images' => $this->getOptionImages(),
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\ConfigurableProduct\Model\Product\Type\Configurable\Variations;
8+
9+
/**
10+
* Configurable product variation prices.
11+
*/
12+
class Prices
13+
{
14+
/**
15+
* @var \Magento\Framework\Locale\Format
16+
*/
17+
private $localeFormat;
18+
19+
/**
20+
* Prices constructor.
21+
* @param \Magento\Framework\Locale\Format $localeFormat
22+
*/
23+
public function __construct(\Magento\Framework\Locale\Format $localeFormat)
24+
{
25+
$this->localeFormat = $localeFormat;
26+
}
27+
28+
/**
29+
* Get product prices for configurable variations
30+
*
31+
* @param \Magento\Framework\Pricing\PriceInfo\Base $priceInfo
32+
* @return array
33+
*/
34+
public function getFormattedPrices(\Magento\Framework\Pricing\PriceInfo\Base $priceInfo)
35+
{
36+
$regularPrice = $priceInfo->getPrice('regular_price');
37+
$finalPrice = $priceInfo->getPrice('final_price');
38+
39+
return [
40+
'oldPrice' => [
41+
'amount' => $this->localeFormat->getNumber($regularPrice->getAmount()->getValue()),
42+
],
43+
'basePrice' => [
44+
'amount' => $this->localeFormat->getNumber($finalPrice->getAmount()->getBaseAmount()),
45+
],
46+
'finalPrice' => [
47+
'amount' => $this->localeFormat->getNumber($finalPrice->getAmount()->getValue()),
48+
],
49+
];
50+
}
51+
}

app/code/Magento/ConfigurableProduct/Test/Unit/Block/Product/View/Type/ConfigurableTest.php

Lines changed: 50 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ class ConfigurableTest extends \PHPUnit\Framework\TestCase
4848
*/
4949
private $priceCurrency;
5050

51+
/**
52+
* @var \Magento\Directory\Model\Currency|\PHPUnit_Framework_MockObject_MockObject
53+
*/
54+
private $currency;
55+
5156
/**
5257
* @var \Magento\ConfigurableProduct\Model\ConfigurableAttributeData|\PHPUnit_Framework_MockObject_MockObject
5358
*/
@@ -73,6 +78,11 @@ class ConfigurableTest extends \PHPUnit\Framework\TestCase
7378
*/
7479
private $customerSession;
7580

81+
/**
82+
* @var \PHPUnit_Framework_MockObject_MockObject
83+
*/
84+
private $variationPricesMock;
85+
7686
protected function setUp()
7787
{
7888
$this->mockContextObject();
@@ -122,6 +132,9 @@ protected function setUp()
122132
$this->context->expects($this->once())
123133
->method('getResolver')
124134
->willReturn($fileResolverMock);
135+
$this->currency = $this->getMockBuilder(\Magento\Directory\Model\Currency::class)
136+
->disableOriginalConstructor()
137+
->getMock();
125138
$this->configurableAttributeData = $this->getMockBuilder(
126139
\Magento\ConfigurableProduct\Model\ConfigurableAttributeData::class
127140
)
@@ -136,6 +149,10 @@ protected function setUp()
136149
->disableOriginalConstructor()
137150
->getMock();
138151

152+
$this->variationPricesMock = $this->createMock(
153+
\Magento\ConfigurableProduct\Model\Product\Type\Configurable\Variations\Prices::class
154+
);
155+
139156
$this->block = new \Magento\ConfigurableProduct\Block\Product\View\Type\Configurable(
140157
$this->context,
141158
$this->arrayUtils,
@@ -147,7 +164,8 @@ protected function setUp()
147164
$this->configurableAttributeData,
148165
[],
149166
$this->localeFormat,
150-
$this->customerSession
167+
$this->customerSession,
168+
$this->variationPricesMock
151169
);
152170
}
153171

@@ -192,10 +210,10 @@ public function cacheKeyProvider() : array
192210
2 => null,
193211
'base_url' => null,
194212
'template' => null,
195-
3 => '$',
213+
3 => 'USD',
196214
4 => null,
197215
],
198-
'$',
216+
'USD',
199217
null,
200218
]
201219
];
@@ -223,7 +241,10 @@ public function testGetCacheKeyInfo(array $expected, string $priceCurrency = nul
223241
->method('getStore')
224242
->willReturn($storeMock);
225243
$this->priceCurrency->expects($this->once())
226-
->method('getCurrencySymbol')
244+
->method('getCurrency')
245+
->willReturn($this->currency);
246+
$this->currency->expects($this->once())
247+
->method('getCode')
227248
->willReturn($priceCurrency);
228249
$this->customerSession->expects($this->once())
229250
->method('getCustomerGroupId')
@@ -249,12 +270,8 @@ public function testGetJsonConfig()
249270
'getAmount',
250271
])
251272
->getMockForAbstractClass();
252-
$priceMock->expects($this->any())
253-
->method('getAmount')
254-
->willReturn($amountMock);
255-
273+
$priceMock->expects($this->any())->method('getAmount')->willReturn($amountMock);
256274
$tierPriceMock = $this->getTierPriceMock($amountMock, $priceQty, $percentage);
257-
258275
$productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
259276
->disableOriginalConstructor()
260277
->getMock();
@@ -272,27 +289,16 @@ public function testGetJsonConfig()
272289
['tier_price', $tierPriceMock],
273290
]);
274291

275-
$productMock->expects($this->any())
276-
->method('getTypeInstance')
277-
->willReturn($productTypeMock);
278-
$productMock->expects($this->any())
279-
->method('getPriceInfo')
280-
->willReturn($priceInfoMock);
281-
$productMock->expects($this->any())
282-
->method('isSaleable')
283-
->willReturn(true);
284-
$productMock->expects($this->any())
285-
->method('getId')
286-
->willReturn($productId);
292+
$productMock->expects($this->any())->method('getTypeInstance')->willReturn($productTypeMock);
293+
$productMock->expects($this->any())->method('getPriceInfo')->willReturn($priceInfoMock);
294+
$productMock->expects($this->any())->method('isSaleable')->willReturn(true);
295+
$productMock->expects($this->any())->method('getId')->willReturn($productId);
287296

288297
$this->helper->expects($this->any())
289298
->method('getOptions')
290299
->with($productMock, [$productMock])
291300
->willReturn([]);
292-
293-
$this->product->expects($this->any())
294-
->method('getSkipSaleableCheck')
295-
->willReturn(true);
301+
$this->product->expects($this->any())->method('getSkipSaleableCheck')->willReturn(true);
296302

297303
$attributesData = [
298304
'attributes' => [],
@@ -304,9 +310,7 @@ public function testGetJsonConfig()
304310
->with($productMock, [])
305311
->willReturn($attributesData);
306312

307-
$this->localeFormat->expects($this->any())
308-
->method('getPriceFormat')
309-
->willReturn([]);
313+
$this->localeFormat->expects($this->atLeastOnce())->method('getPriceFormat')->willReturn([]);
310314
$this->localeFormat->expects($this->any())
311315
->method('getNumber')
312316
->willReturnMap([
@@ -315,16 +319,29 @@ public function testGetJsonConfig()
315319
[$percentage, $percentage],
316320
]);
317321

322+
$this->variationPricesMock->expects($this->once())
323+
->method('getFormattedPrices')
324+
->with($priceInfoMock)
325+
->willReturn(
326+
[
327+
'oldPrice' => [
328+
'amount' => $amount,
329+
],
330+
'basePrice' => [
331+
'amount' => $amount,
332+
],
333+
'finalPrice' => [
334+
'amount' => $amount,
335+
],
336+
]
337+
);
338+
318339
$expectedArray = $this->getExpectedArray($productId, $amount, $priceQty, $percentage);
319340
$expectedJson = json_encode($expectedArray);
320341

321-
$this->jsonEncoder->expects($this->once())
322-
->method('encode')
323-
->with($expectedArray)
324-
->willReturn($expectedJson);
342+
$this->jsonEncoder->expects($this->once())->method('encode')->with($expectedArray)->willReturn($expectedJson);
325343

326344
$this->block->setData('product', $productMock);
327-
328345
$result = $this->block->getJsonConfig();
329346
$this->assertEquals($expectedJson, $result);
330347
}

0 commit comments

Comments
 (0)