Skip to content

Commit e649b4c

Browse files
authored
Merge pull request magento#1495 from magento-borg/MAGETWO-72469
Merge 2.2-develop into develop
2 parents 75155ae + 84172ef commit e649b4c

File tree

236 files changed

+9986
-2158
lines changed

Some content is hidden

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

236 files changed

+9986
-2158
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', 15);
67-
ini_set('serialize_precision', 15);
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/AdvancedPricingImportExport/Model/Indexer/Product/Price/Plugin/Import.php

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,21 @@
77

88
use Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing;
99

10-
class Import extends \Magento\Catalog\Model\Indexer\Product\Price\Plugin\AbstractPlugin
10+
class Import
1111
{
12+
/**
13+
* @var \Magento\Framework\Indexer\IndexerRegistry
14+
*/
15+
private $indexerRegistry;
16+
17+
/**
18+
* @param \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry
19+
*/
20+
public function __construct(\Magento\Framework\Indexer\IndexerRegistry $indexerRegistry)
21+
{
22+
$this->indexerRegistry = $indexerRegistry;
23+
}
24+
1225
/**
1326
* After import handler
1427
*
@@ -18,9 +31,7 @@ class Import extends \Magento\Catalog\Model\Indexer\Product\Price\Plugin\Abstrac
1831
*/
1932
public function afterSaveAdvancedPricing(AdvancedPricing $subject)
2033
{
21-
if (!$this->getPriceIndexer()->isScheduled()) {
22-
$this->invalidateIndexer();
23-
}
34+
$this->invalidateIndexer();
2435
}
2536

2637
/**
@@ -32,18 +43,19 @@ public function afterSaveAdvancedPricing(AdvancedPricing $subject)
3243
*/
3344
public function afterDeleteAdvancedPricing(AdvancedPricing $subject)
3445
{
35-
if (!$this->getPriceIndexer()->isScheduled()) {
36-
$this->invalidateIndexer();
37-
}
46+
$this->invalidateIndexer();
3847
}
3948

4049
/**
41-
* Get price indexer
50+
* Invalidate indexer
4251
*
43-
* @return \Magento\Framework\Indexer\IndexerInterface
52+
* @return void
4453
*/
45-
protected function getPriceIndexer()
54+
private function invalidateIndexer()
4655
{
47-
return $this->indexerRegistry->get(\Magento\Catalog\Model\Indexer\Product\Price\Processor::INDEXER_ID);
56+
$priceIndexer = $this->indexerRegistry->get(\Magento\Catalog\Model\Indexer\Product\Price\Processor::INDEXER_ID);
57+
if (!$priceIndexer->isScheduled()) {
58+
$priceIndexer->invalidate();
59+
}
4860
}
4961
}

app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Indexer/Product/Price/Plugin/ImportTest.php

Lines changed: 47 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,22 @@ class ImportTest extends \PHPUnit\Framework\TestCase
1313
/**
1414
* @var \Magento\Framework\Indexer\IndexerInterface |\PHPUnit_Framework_MockObject_MockObject
1515
*/
16-
protected $indexer;
16+
private $indexer;
1717

1818
/**
1919
* @var Import |\PHPUnit_Framework_MockObject_MockObject
2020
*/
21-
protected $import;
21+
private $import;
2222

2323
/**
2424
* @var \Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing|\PHPUnit_Framework_MockObject_MockObject
2525
*/
26-
protected $advancedPricing;
26+
private $advancedPricing;
27+
28+
/**
29+
* @var \Magento\Framework\Indexer\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject
30+
*/
31+
private $indexerRegistry;
2732

2833
protected function setUp()
2934
{
@@ -33,29 +38,58 @@ protected function setUp()
3338
'',
3439
false
3540
);
36-
$this->import = $this->createPartialMock(
37-
\Magento\AdvancedPricingImportExport\Model\Indexer\Product\Price\Plugin\Import::class,
38-
['getPriceIndexer', 'invalidateIndexer']
41+
$this->indexerRegistry = $this->createMock(
42+
\Magento\Framework\Indexer\IndexerRegistry::class
43+
);
44+
$this->import = new \Magento\AdvancedPricingImportExport\Model\Indexer\Product\Price\Plugin\Import(
45+
$this->indexerRegistry
3946
);
4047
$this->advancedPricing = $this->createMock(
4148
\Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing::class
4249
);
43-
$this->import->expects($this->any())->method('getPriceIndexer')->willReturn($this->indexer);
50+
$this->indexerRegistry->expects($this->any())
51+
->method('get')
52+
->with(\Magento\Catalog\Model\Indexer\Product\Price\Processor::INDEXER_ID)
53+
->willReturn($this->indexer);
4454
}
4555

46-
public function testAfterSaveAdvancedPricing()
56+
public function testAfterSaveReindexIsOnSave()
4757
{
48-
$this->indexer->expects($this->once())->method('isScheduled')->willReturn(false);
49-
$this->import->expects($this->once())->method('invalidateIndexer');
58+
$this->indexer->expects($this->once())
59+
->method('isScheduled')
60+
->willReturn(false);
61+
$this->indexer->expects($this->once())
62+
->method('invalidate');
63+
$this->import->afterSaveAdvancedPricing($this->advancedPricing);
64+
}
5065

66+
public function testAfterSaveReindexIsOnSchedule()
67+
{
68+
$this->indexer->expects($this->once())
69+
->method('isScheduled')
70+
->willReturn(true);
71+
$this->indexer->expects($this->never())
72+
->method('invalidate');
5173
$this->import->afterSaveAdvancedPricing($this->advancedPricing);
5274
}
5375

54-
public function testAfterDeleteAdvancedPricing()
76+
public function testAfterDeleteReindexIsOnSave()
5577
{
56-
$this->indexer->expects($this->once())->method('isScheduled')->willReturn(false);
57-
$this->import->expects($this->once())->method('invalidateIndexer');
78+
$this->indexer->expects($this->once())
79+
->method('isScheduled')
80+
->willReturn(false);
81+
$this->indexer->expects($this->once())
82+
->method('invalidate');
83+
$this->import->afterSaveAdvancedPricing($this->advancedPricing);
84+
}
5885

86+
public function testAfterDeleteReindexIsOnSchedule()
87+
{
88+
$this->indexer->expects($this->once())
89+
->method('isScheduled')
90+
->willReturn(true);
91+
$this->indexer->expects($this->never())
92+
->method('invalidate');
5993
$this->import->afterSaveAdvancedPricing($this->advancedPricing);
6094
}
6195
}

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/Catalog/Controller/Adminhtml/Category.php

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,21 @@ abstract class Category extends \Magento\Backend\App\Action
1818
const ADMIN_RESOURCE = 'Magento_Catalog::categories';
1919

2020
/**
21-
* @var \Magento\Framework\Stdlib\DateTime\Filter\DateTime
21+
* @var \Magento\Framework\Stdlib\DateTime\Filter\Date
2222
*/
23-
private $dateTimeFilter;
23+
protected $dateFilter;
24+
25+
/**
26+
* @param \Magento\Backend\App\Action\Context $context
27+
* @param \Magento\Framework\Stdlib\DateTime\Filter\Date|null $dateFilter
28+
*/
29+
public function __construct(
30+
\Magento\Backend\App\Action\Context $context,
31+
\Magento\Framework\Stdlib\DateTime\Filter\Date $dateFilter = null
32+
) {
33+
$this->dateFilter = $dateFilter;
34+
parent::__construct($context);
35+
}
2436

2537
/**
2638
* Initialize requested category and put it into registry.
@@ -125,20 +137,6 @@ protected function ajaxRequestResponse($category, $resultPage)
125137
return $resultJson;
126138
}
127139

128-
/**
129-
* @return \Magento\Framework\Stdlib\DateTime\Filter\DateTime
130-
*
131-
* @deprecated 101.0.0
132-
*/
133-
private function getDateTimeFilter()
134-
{
135-
if ($this->dateTimeFilter === null) {
136-
$this->dateTimeFilter = \Magento\Framework\App\ObjectManager::getInstance()
137-
->get(\Magento\Framework\Stdlib\DateTime\Filter\DateTime::class);
138-
}
139-
return $this->dateTimeFilter;
140-
}
141-
142140
/**
143141
* Datetime data preprocessing
144142
*
@@ -154,7 +152,7 @@ protected function dateTimePreprocessing($category, $postData)
154152
foreach ($attributes as $attrKey => $attribute) {
155153
if ($attribute->getBackend()->getType() == 'datetime') {
156154
if (array_key_exists($attrKey, $postData) && $postData[$attrKey] != '') {
157-
$dateFieldFilters[$attrKey] = $this->getDateTimeFilter();
155+
$dateFieldFilters[$attrKey] = $this->dateFilter;
158156
}
159157
}
160158
}

app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ class Save extends \Magento\Catalog\Controller\Adminhtml\Category
6161
* @param \Magento\Framework\Controller\Result\RawFactory $resultRawFactory
6262
* @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
6363
* @param \Magento\Framework\View\LayoutFactory $layoutFactory
64+
* @param \Magento\Framework\Stdlib\DateTime\Filter\Date $dateFilter
6465
* @param StoreManagerInterface $storeManager
6566
* @param \Magento\Eav\Model\Config $eavConfig
6667
*/
@@ -69,10 +70,11 @@ public function __construct(
6970
\Magento\Framework\Controller\Result\RawFactory $resultRawFactory,
7071
\Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory,
7172
\Magento\Framework\View\LayoutFactory $layoutFactory,
73+
\Magento\Framework\Stdlib\DateTime\Filter\Date $dateFilter,
7274
StoreManagerInterface $storeManager,
7375
\Magento\Eav\Model\Config $eavConfig = null
7476
) {
75-
parent::__construct($context);
77+
parent::__construct($context, $dateFilter);
7678
$this->resultRawFactory = $resultRawFactory;
7779
$this->resultJsonFactory = $resultJsonFactory;
7880
$this->layoutFactory = $layoutFactory;

app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Magento\Catalog\Model\Product\Initialization\Helper\ProductLinks;
1313
use Magento\Catalog\Model\Product\Link\Resolver as LinkResolver;
1414
use Magento\Framework\App\ObjectManager;
15+
use Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\AttributeFilter;
1516

1617
/**
1718
* @api
@@ -84,6 +85,11 @@ class Helper
8485
*/
8586
private $linkTypeProvider;
8687

88+
/**
89+
* @var AttributeFilter
90+
*/
91+
private $attributeFilter;
92+
8793
/**
8894
* Constructor
8995
*
@@ -97,6 +103,7 @@ class Helper
97103
* @param \Magento\Catalog\Api\Data\ProductLinkInterfaceFactory|null $productLinkFactory
98104
* @param \Magento\Catalog\Api\ProductRepositoryInterface|null $productRepository
99105
* @param \Magento\Catalog\Model\Product\LinkTypeProvider|null $linkTypeProvider
106+
* @param AttributeFilter|null $attributeFilter
100107
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
101108
*/
102109
public function __construct(
@@ -109,7 +116,8 @@ public function __construct(
109116
\Magento\Catalog\Api\Data\ProductCustomOptionInterfaceFactory $customOptionFactory = null,
110117
\Magento\Catalog\Api\Data\ProductLinkInterfaceFactory $productLinkFactory = null,
111118
\Magento\Catalog\Api\ProductRepositoryInterface $productRepository = null,
112-
\Magento\Catalog\Model\Product\LinkTypeProvider $linkTypeProvider = null
119+
\Magento\Catalog\Model\Product\LinkTypeProvider $linkTypeProvider = null,
120+
AttributeFilter $attributeFilter = null
113121
) {
114122
$this->request = $request;
115123
$this->storeManager = $storeManager;
@@ -125,6 +133,8 @@ public function __construct(
125133
->get(\Magento\Catalog\Api\ProductRepositoryInterface::class);
126134
$this->linkTypeProvider = $linkTypeProvider ?: \Magento\Framework\App\ObjectManager::getInstance()
127135
->get(\Magento\Catalog\Model\Product\LinkTypeProvider::class);
136+
$this->attributeFilter = $attributeFilter ?: \Magento\Framework\App\ObjectManager::getInstance()
137+
->get(AttributeFilter::class);
128138
}
129139

130140
/**
@@ -187,6 +197,11 @@ public function initializeFromData(\Magento\Catalog\Model\Product $product, arra
187197
$productOptions = [];
188198
}
189199
$productData['tier_price'] = isset($productData['tier_price']) ? $productData['tier_price'] : [];
200+
201+
$useDefaults = (array)$this->request->getPost('use_default', []);
202+
203+
$productData = $this->attributeFilter->prepareProductAttributes($product, $productData, $useDefaults);
204+
190205
$product->addData($productData);
191206

192207
if ($wasLockedMedia) {
@@ -196,8 +211,6 @@ public function initializeFromData(\Magento\Catalog\Model\Product $product, arra
196211
/**
197212
* Check "Use Default Value" checkboxes values
198213
*/
199-
$useDefaults = (array)$this->request->getPost('use_default', []);
200-
201214
foreach ($useDefaults as $attributeCode => $useDefaultState) {
202215
if ($useDefaultState) {
203216
$product->setData($attributeCode, null);

0 commit comments

Comments
 (0)