Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit c3d2df7

Browse files
author
Volodymyr Kublytskyi
committed
Merge remote-tracking branch 'mainline/2.3-develop' into msi-core-changes-no-history-2
2 parents 100dd4b + 7843add commit c3d2df7

File tree

17 files changed

+394
-109
lines changed

17 files changed

+394
-109
lines changed

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/ConfigurableProduct/Block/Product/View/Type/Configurable.php

Lines changed: 12 additions & 15 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,
@@ -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: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\ConfigurableProduct\Model\Product\Type\Configurable\Variations;
10+
11+
/**
12+
* Configurable product variation prices.
13+
*/
14+
class Prices
15+
{
16+
/**
17+
* @var \Magento\Framework\Locale\Format
18+
*/
19+
private $localeFormat;
20+
21+
/**
22+
* Prices constructor.
23+
* @param \Magento\Framework\Locale\Format $localeFormat
24+
*/
25+
public function __construct(\Magento\Framework\Locale\Format $localeFormat)
26+
{
27+
$this->localeFormat = $localeFormat;
28+
}
29+
30+
/**
31+
* Get product prices for configurable variations
32+
*
33+
* @param \Magento\Framework\Pricing\PriceInfo\Base $priceInfo
34+
* @return array
35+
*/
36+
public function getFormattedPrices(\Magento\Framework\Pricing\PriceInfo\Base $priceInfo)
37+
{
38+
$regularPrice = $priceInfo->getPrice('regular_price');
39+
$finalPrice = $priceInfo->getPrice('final_price');
40+
41+
return [
42+
'oldPrice' => [
43+
'amount' => $this->localeFormat->getNumber($regularPrice->getAmount()->getValue()),
44+
],
45+
'basePrice' => [
46+
'amount' => $this->localeFormat->getNumber($finalPrice->getAmount()->getBaseAmount()),
47+
],
48+
'finalPrice' => [
49+
'amount' => $this->localeFormat->getNumber($finalPrice->getAmount()->getValue()),
50+
],
51+
];
52+
}
53+
}

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

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ class ConfigurableTest extends \PHPUnit\Framework\TestCase
7878
*/
7979
private $customerSession;
8080

81+
/**
82+
* @var \PHPUnit_Framework_MockObject_MockObject
83+
*/
84+
private $variationPricesMock;
85+
8186
protected function setUp()
8287
{
8388
$this->mockContextObject();
@@ -144,6 +149,10 @@ protected function setUp()
144149
->disableOriginalConstructor()
145150
->getMock();
146151

152+
$this->variationPricesMock = $this->createMock(
153+
\Magento\ConfigurableProduct\Model\Product\Type\Configurable\Variations\Prices::class
154+
);
155+
147156
$this->block = new \Magento\ConfigurableProduct\Block\Product\View\Type\Configurable(
148157
$this->context,
149158
$this->arrayUtils,
@@ -155,7 +164,8 @@ protected function setUp()
155164
$this->configurableAttributeData,
156165
[],
157166
$this->localeFormat,
158-
$this->customerSession
167+
$this->customerSession,
168+
$this->variationPricesMock
159169
);
160170
}
161171

@@ -260,12 +270,8 @@ public function testGetJsonConfig()
260270
'getAmount',
261271
])
262272
->getMockForAbstractClass();
263-
$priceMock->expects($this->any())
264-
->method('getAmount')
265-
->willReturn($amountMock);
266-
273+
$priceMock->expects($this->any())->method('getAmount')->willReturn($amountMock);
267274
$tierPriceMock = $this->getTierPriceMock($amountMock, $priceQty, $percentage);
268-
269275
$productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
270276
->disableOriginalConstructor()
271277
->getMock();
@@ -283,27 +289,16 @@ public function testGetJsonConfig()
283289
['tier_price', $tierPriceMock],
284290
]);
285291

286-
$productMock->expects($this->any())
287-
->method('getTypeInstance')
288-
->willReturn($productTypeMock);
289-
$productMock->expects($this->any())
290-
->method('getPriceInfo')
291-
->willReturn($priceInfoMock);
292-
$productMock->expects($this->any())
293-
->method('isSaleable')
294-
->willReturn(true);
295-
$productMock->expects($this->any())
296-
->method('getId')
297-
->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);
298296

299297
$this->helper->expects($this->any())
300298
->method('getOptions')
301299
->with($productMock, [$productMock])
302300
->willReturn([]);
303-
304-
$this->product->expects($this->any())
305-
->method('getSkipSaleableCheck')
306-
->willReturn(true);
301+
$this->product->expects($this->any())->method('getSkipSaleableCheck')->willReturn(true);
307302

308303
$attributesData = [
309304
'attributes' => [],
@@ -315,9 +310,7 @@ public function testGetJsonConfig()
315310
->with($productMock, [])
316311
->willReturn($attributesData);
317312

318-
$this->localeFormat->expects($this->any())
319-
->method('getPriceFormat')
320-
->willReturn([]);
313+
$this->localeFormat->expects($this->atLeastOnce())->method('getPriceFormat')->willReturn([]);
321314
$this->localeFormat->expects($this->any())
322315
->method('getNumber')
323316
->willReturnMap([
@@ -326,16 +319,29 @@ public function testGetJsonConfig()
326319
[$percentage, $percentage],
327320
]);
328321

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+
329339
$expectedArray = $this->getExpectedArray($productId, $amount, $priceQty, $percentage);
330340
$expectedJson = json_encode($expectedArray);
331341

332-
$this->jsonEncoder->expects($this->once())
333-
->method('encode')
334-
->with($expectedArray)
335-
->willReturn($expectedJson);
342+
$this->jsonEncoder->expects($this->once())->method('encode')->with($expectedArray)->willReturn($expectedJson);
336343

337344
$this->block->setData('product', $productMock);
338-
339345
$result = $this->block->getJsonConfig();
340346
$this->assertEquals($expectedJson, $result);
341347
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\ConfigurableProduct\Test\Unit\Model\Product\Type\Configurable\Variations;
10+
11+
use PHPUnit\Framework\TestCase;
12+
13+
class PricesTest extends TestCase
14+
{
15+
/**
16+
* @var \PHPUnit_Framework_MockObject_MockObject
17+
*/
18+
private $localeFormatMock;
19+
20+
/**
21+
* @var \Magento\ConfigurableProduct\Model\Product\Type\Configurable\Variations\Prices
22+
*/
23+
private $model;
24+
25+
protected function setUp()
26+
{
27+
$this->localeFormatMock = $this->createMock(\Magento\Framework\Locale\Format::class);
28+
$this->model = new \Magento\ConfigurableProduct\Model\Product\Type\Configurable\Variations\Prices(
29+
$this->localeFormatMock
30+
);
31+
}
32+
33+
public function testGetFormattedPrices()
34+
{
35+
$expected = [
36+
'oldPrice' => [
37+
'amount' => 500
38+
],
39+
'basePrice' => [
40+
'amount' => 1000
41+
],
42+
'finalPrice' => [
43+
'amount' => 500
44+
]
45+
];
46+
$priceInfoMock = $this->createMock(\Magento\Framework\Pricing\PriceInfo\Base::class);
47+
$priceMock = $this->createMock(\Magento\Framework\Pricing\Price\PriceInterface::class);
48+
$priceInfoMock->expects($this->atLeastOnce())->method('getPrice')->willReturn($priceMock);
49+
50+
$amountMock = $this->createMock(\Magento\Framework\Pricing\Amount\AmountInterface::class);
51+
$amountMock->expects($this->atLeastOnce())->method('getValue')->willReturn(500);
52+
$amountMock->expects($this->atLeastOnce())->method('getBaseAmount')->willReturn(1000);
53+
$priceMock->expects($this->atLeastOnce())->method('getAmount')->willReturn($amountMock);
54+
55+
$this->localeFormatMock->expects($this->atLeastOnce())
56+
->method('getNumber')
57+
->withConsecutive([500], [1000], [500])
58+
->will($this->onConsecutiveCalls(500, 1000, 500));
59+
60+
$this->assertEquals($expected, $this->model->getFormattedPrices($priceInfoMock));
61+
}
62+
}

app/code/Magento/ImportExport/Block/Adminhtml/Export/Filter.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ protected function _getMultiSelectHtmlWithValue(Attribute $attribute, $value)
142142
if ($attribute->getFilterOptions()) {
143143
$options = $attribute->getFilterOptions();
144144
} else {
145-
$options = $attribute->getSource()->getAllOptions(false);
145+
$options = $attribute->getSource()->getAllOptions();
146146

147147
foreach ($options as $key => $optionParams) {
148148
if ('' === $optionParams['value']) {
@@ -151,12 +151,13 @@ protected function _getMultiSelectHtmlWithValue(Attribute $attribute, $value)
151151
}
152152
}
153153
}
154+
154155
if ($size = count($options)) {
155156
$arguments = [
156157
'name' => $this->getFilterElementName($attribute->getAttributeCode()) . '[]',
157158
'id' => $this->getFilterElementId($attribute->getAttributeCode()),
158159
'class' => 'multiselect multiselect-export-filter',
159-
'extra_params' => 'multiple="multiple" size="' . ($size > 5 ? 5 : ($size < 2 ? 2 : $size)),
160+
'extra_params' => 'multiple="multiple" size="' . ($size > 5 ? 5 : ($size < 2 ? 2 : $size)) . '"',
160161
];
161162
/** @var $selectBlock \Magento\Framework\View\Element\Html\Select */
162163
$selectBlock = $this->_layout->createBlock(
@@ -364,6 +365,9 @@ public function decorateFilter($value, Attribute $row, \Magento\Framework\DataOb
364365
case \Magento\ImportExport\Model\Export::FILTER_TYPE_SELECT:
365366
$cell = $this->_getSelectHtmlWithValue($row, $value);
366367
break;
368+
case \Magento\ImportExport\Model\Export::FILTER_TYPE_MULTISELECT:
369+
$cell = $this->_getMultiSelectHtmlWithValue($row, $value);
370+
break;
367371
case \Magento\ImportExport\Model\Export::FILTER_TYPE_INPUT:
368372
$cell = $this->_getInputHtmlWithValue($row, $value);
369373
break;

0 commit comments

Comments
 (0)