Skip to content

Commit a04f39e

Browse files
committed
Merge remote-tracking branch 'mainline/2.2-develop' into MAGETWO-72415
2 parents 3ec31ee + 89db29c commit a04f39e

File tree

93 files changed

+3791
-622
lines changed

Some content is hidden

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

93 files changed

+3791
-622
lines changed

app/bootstrap.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,6 @@
6262

6363
date_default_timezone_set('UTC');
6464

65-
/* Adjustment of precision value for several versions of PHP */
66-
ini_set('precision', 17);
67-
ini_set('serialize_precision', 17);
65+
/* For data consistency between displaying (printing) and serialization a float number */
66+
ini_set('precision', 14);
67+
ini_set('serialize_precision', 14);

app/code/Magento/Backend/view/adminhtml/templates/widget/grid.phtml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ $numColumns = sizeof($block->getColumns());
149149
<?php endif; ?>
150150

151151
<?php if (strpos($block->getRowClickCallback(), 'order.') !== false): ?>
152-
deps.push('Magento_Sales/order/create/form')
152+
deps.push('Magento_Sales/order/create/form');
153+
deps.push('jquery');
153154
<?php endif; ?>
154155

155156
deps.push('mage/adminhtml/grid');

app/code/Magento/Bundle/Test/Unit/Pricing/Price/TierPriceTest.php

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -180,19 +180,28 @@ public function providerForGetterTierPriceList()
180180
/**
181181
* @dataProvider providerForTestGetSavePercent
182182
*/
183-
public function testGetSavePercent($baseAmount, $savePercent)
183+
public function testGetSavePercent($baseAmount, $tierPrice, $savePercent)
184184
{
185-
$basePrice = 10.;
185+
/** @var \Magento\Framework\Pricing\Amount\AmountInterface|\PHPUnit_Framework_MockObject_MockObject $amount */
186186
$amount = $this->getMockForAbstractClass(\Magento\Framework\Pricing\Amount\AmountInterface::class);
187-
$amount->expects($this->once())->method('getBaseAmount')->willReturn($baseAmount);
187+
$amount->expects($this->any())
188+
->method('getValue')
189+
->will($this->returnValue($tierPrice));
190+
191+
$priceAmount = $this->getMockForAbstractClass(\Magento\Framework\Pricing\Amount\AmountInterface::class);
192+
$priceAmount->expects($this->any())
193+
->method('getValue')
194+
->will($this->returnValue($baseAmount));
195+
188196
$price = $this->createMock(\Magento\Framework\Pricing\Price\PriceInterface::class);
189197
$price->expects($this->any())
190-
->method('getValue')
191-
->will($this->returnValue($basePrice));
198+
->method('getAmount')
199+
->will($this->returnValue($priceAmount));
192200

193201
$this->priceInfo->expects($this->any())
194202
->method('getPrice')
195203
->will($this->returnValue($price));
204+
196205
$this->assertEquals($savePercent, $this->model->getSavePercent($amount));
197206
}
198207

@@ -202,8 +211,8 @@ public function testGetSavePercent($baseAmount, $savePercent)
202211
public function providerForTestGetSavePercent()
203212
{
204213
return [
205-
'no fraction' => [9.0000, 10],
206-
'lower half' => [9.1234, 9],
214+
'no fraction' => [9.0000, 8.1, 10],
215+
'lower half' => [9.1234, 8.3, 9],
207216
];
208217
}
209218
}

app/code/Magento/BundleImportExport/Model/Import/Product/Type/Bundle.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,10 @@ public function __construct(
168168
*/
169169
protected function parseSelections($rowData, $entityId)
170170
{
171+
if (empty($rowData['bundle_values'])) {
172+
return [];
173+
}
174+
171175
$rowData['bundle_values'] = str_replace(
172176
self::BEFORE_OPTION_VALUE_DELIMITER,
173177
$this->_entityModel->getMultipleValueSeparator(),

app/code/Magento/BundleImportExport/Test/Unit/Model/Import/Product/Type/BundleTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,11 @@ public function saveDataProvider()
294294
'bunch' => ['bundle_values' => 'value1', 'sku' => 'sku', 'name' => 'name'],
295295
'allowImport' => false
296296
],
297+
'Import without bundle values' => [
298+
'skus' => ['newSku' => ['sku' => ['sku' => 'sku', 'entity_id' => 3, 'type_id' => 'bundle']]],
299+
'bunch' => ['sku' => 'sku', 'name' => 'name'],
300+
'allowImport' => true,
301+
],
297302
[
298303
'skus' => ['newSku' => [
299304
'sku' => ['sku' => 'sku', 'entity_id' => 3, 'type_id' => 'bundle'],

app/code/Magento/Catalog/Model/Config/Source/Product/Options/Price.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,21 @@
1414
*/
1515
class Price implements ProductPriceOptionsInterface
1616
{
17+
/**
18+
* Store manager.
19+
*
20+
* @var \Magento\Store\Model\StoreManagerInterface
21+
*/
22+
private $storeManager;
23+
24+
/**
25+
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
26+
*/
27+
public function __construct(\Magento\Store\Model\StoreManagerInterface $storeManager)
28+
{
29+
$this->storeManager = $storeManager;
30+
}
31+
1732
/**
1833
* {@inheritdoc}
1934
*
@@ -26,4 +41,27 @@ public function toOptionArray()
2641
['value' => self::VALUE_PERCENT, 'label' => __('Percent')],
2742
];
2843
}
44+
45+
/**
46+
* Get option array of prefixes.
47+
*
48+
* @return array
49+
*/
50+
public function prefixesToOptionArray()
51+
{
52+
return [
53+
['value' => self::VALUE_FIXED, 'label' => $this->getCurrencySymbol()],
54+
['value' => self::VALUE_PERCENT, 'label' => '%'],
55+
];
56+
}
57+
58+
/**
59+
* Get currency symbol.
60+
*
61+
* @return string
62+
*/
63+
private function getCurrencySymbol()
64+
{
65+
return $this->storeManager->getStore()->getBaseCurrency()->getCurrencySymbol();
66+
}
2967
}

app/code/Magento/Catalog/Pricing/Price/TierPrice.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,14 +215,21 @@ protected function getBasePrice()
215215
}
216216

217217
/**
218+
* Calculates savings percentage according to the given tier price amount
219+
* and related product price amount.
220+
*
218221
* @param AmountInterface $amount
222+
*
219223
* @return float
220224
*/
221225
public function getSavePercent(AmountInterface $amount)
222226
{
227+
$productPriceAmount = $this->priceInfo->getPrice(
228+
FinalPrice::PRICE_CODE
229+
)->getAmount();
230+
223231
return round(
224-
100 - ((100 / $this->priceInfo->getPrice(FinalPrice::PRICE_CODE)->getValue())
225-
* $amount->getBaseAmount())
232+
100 - ((100 / $productPriceAmount->getValue()) * $amount->getValue())
226233
);
227234
}
228235

app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/DefaultValidatorTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ class DefaultValidatorTest extends \PHPUnit\Framework\TestCase
2121
protected function setUp()
2222
{
2323
$configMock = $this->createMock(\Magento\Catalog\Model\ProductOptions\ConfigInterface::class);
24-
$priceConfigMock = new \Magento\Catalog\Model\Config\Source\Product\Options\Price();
24+
$storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class);
25+
$priceConfigMock = new \Magento\Catalog\Model\Config\Source\Product\Options\Price($storeManagerMock);
2526
$config = [
2627
[
2728
'label' => 'group label 1',

app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/FileTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ class FileTest extends \PHPUnit\Framework\TestCase
2121
protected function setUp()
2222
{
2323
$configMock = $this->createMock(\Magento\Catalog\Model\ProductOptions\ConfigInterface::class);
24-
$priceConfigMock = new \Magento\Catalog\Model\Config\Source\Product\Options\Price();
24+
$storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class);
25+
$priceConfigMock = new \Magento\Catalog\Model\Config\Source\Product\Options\Price($storeManagerMock);
2526
$config = [
2627
[
2728
'label' => 'group label 1',

app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/SelectTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ class SelectTest extends \PHPUnit\Framework\TestCase
2121
protected function setUp()
2222
{
2323
$configMock = $this->createMock(\Magento\Catalog\Model\ProductOptions\ConfigInterface::class);
24-
$priceConfigMock = new \Magento\Catalog\Model\Config\Source\Product\Options\Price();
24+
$storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class);
25+
$priceConfigMock = new \Magento\Catalog\Model\Config\Source\Product\Options\Price($storeManagerMock);
2526
$config = [
2627
[
2728
'label' => 'group label 1',

0 commit comments

Comments
 (0)