Skip to content

Commit cc71ccf

Browse files
authored
Merge pull request #1573 from magento-panda/2.2-stabilization
[KoKoC] 2.2-develop stabilization + cumulative PR merge
2 parents d30f077 + dfd934f commit cc71ccf

File tree

34 files changed

+25437
-6766
lines changed

34 files changed

+25437
-6766
lines changed

app/code/Magento/Catalog/Model/Product/Attribute/Backend/GroupPrice/AbstractGroupPrice.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ protected function modifyPriceData($object, $data)
360360
{
361361
/** @var array $priceItem */
362362
foreach ($data as $key => $priceItem) {
363-
if (isset($priceItem['price']) && $priceItem['price'] > 0) {
363+
if (array_key_exists('price', $priceItem)) {
364364
$data[$key]['website_price'] = $priceItem['price'];
365365
}
366366
if ($priceItem['all_groups']) {

app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/IndexTableRowSizeEstimator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class IndexTableRowSizeEstimator implements \Magento\Framework\Indexer\IndexTabl
1515
/**
1616
* Calculated memory size for one record in catalog_product_index_price table
1717
*/
18-
const MEMORY_SIZE_FOR_ONE_ROW = 120;
18+
const MEMORY_SIZE_FOR_ONE_ROW = 200;
1919

2020
/**
2121
* @var \Magento\Store\Api\WebsiteManagementInterface

app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/TierpriceTest.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ public function testSetPriceData()
141141
{
142142
$attributeName = 'tier_price';
143143
$tierPrices = [
144+
[
145+
'price' => 0,
146+
'all_groups' => 1,
147+
],
144148
[
145149
'price' => 10,
146150
'all_groups' => 1,
@@ -153,6 +157,12 @@ public function testSetPriceData()
153157
$productPrice = 20;
154158
$allCustomersGroupId = 32000;
155159
$finalTierPrices = [
160+
[
161+
'price' => 0,
162+
'all_groups' => 1,
163+
'website_price' => 0,
164+
'cust_group' => 32000,
165+
],
156166
[
157167
'price' => 10,
158168
'all_groups' => 1,
@@ -170,8 +180,11 @@ public function testSetPriceData()
170180
->disableOriginalConstructor()->getMock();
171181
$allCustomersGroup = $this->getMockBuilder(\Magento\Customer\Api\Data\GroupInterface::class)
172182
->disableOriginalConstructor()->getMock();
173-
$this->groupManagement->expects($this->once())->method('getAllCustomersGroup')->willReturn($allCustomersGroup);
174-
$allCustomersGroup->expects($this->once())->method('getId')->willReturn($allCustomersGroupId);
183+
$this->groupManagement
184+
->expects($this->exactly(2))
185+
->method('getAllCustomersGroup')
186+
->willReturn($allCustomersGroup);
187+
$allCustomersGroup->expects($this->exactly(2))->method('getId')->willReturn($allCustomersGroupId);
175188
$object->expects($this->once())->method('getPrice')->willReturn($productPrice);
176189
$this->attribute->expects($this->atLeastOnce())->method('isScopeGlobal')->willReturn(true);
177190
$object->expects($this->once())->method('getStoreId')->willReturn(null);

app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Indexer/Price/IndexTableRowSizeEstimatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ protected function setUp()
3838

3939
public function testEstimateRowSize()
4040
{
41-
$expectedValue = 2400000;
41+
$expectedValue = 4000000;
4242

4343
$this->websiteManagementMock->expects($this->once())->method('getCount')->willReturn(100);
4444
$collectionMock = $this->createMock(\Magento\Customer\Model\ResourceModel\Group\Collection::class);

app/code/Magento/Config/Block/System/Config/Form.php

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -425,24 +425,10 @@ private function getFieldData(\Magento\Config\Model\Config\Structure\Element\Fie
425425
if ($placeholderValue) {
426426
$data = $placeholderValue;
427427
}
428+
428429
if ($data === null) {
429-
if (array_key_exists($path, $this->_configData)) {
430-
$data = $this->_configData[$path];
431-
432-
if ($field->hasBackendModel()) {
433-
$backendModel = $field->getBackendModel();
434-
$backendModel->setPath($path)
435-
->setValue($data)
436-
->setWebsite($this->getWebsiteCode())
437-
->setStore($this->getStoreCode())
438-
->afterLoad();
439-
$data = $backendModel->getValue();
440-
}
441-
} elseif ($field->getConfigPath() !== null) {
442-
$data = $this->getConfigValue($field->getConfigPath());
443-
} else {
444-
$data = $this->getConfigValue($path);
445-
}
430+
$path = $field->getConfigPath() !== null ? $field->getConfigPath() : $path;
431+
$data = $this->getConfigValue($path);
446432
}
447433

448434
return $data;

app/code/Magento/Config/Model/Config/Backend/Serialized.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
*/
66
namespace Magento\Config\Model\Config\Backend;
77

8+
use Magento\Framework\App\Config\Data\ProcessorInterface;
89
use Magento\Framework\App\ObjectManager;
910
use Magento\Framework\Serialize\Serializer\Json;
1011

1112
/**
1213
* @api
1314
* @since 100.0.2
1415
*/
15-
class Serialized extends \Magento\Framework\App\Config\Value
16+
class Serialized extends \Magento\Framework\App\Config\Value implements ProcessorInterface
1617
{
1718
/**
1819
* @var Json
@@ -67,4 +68,12 @@ public function beforeSave()
6768
parent::beforeSave();
6869
return $this;
6970
}
71+
72+
/**
73+
* @inheritdoc
74+
*/
75+
public function processValue($value)
76+
{
77+
return empty($value) ? '' : $this->serializer->unserialize($value);
78+
}
7079
}

app/code/Magento/Config/Test/Unit/Block/System/Config/FormTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -543,12 +543,12 @@ public function initFieldsDataProvider()
543543
return [
544544
[
545545
['section1/group1/field1' => 'some_value'],
546-
false,
547-
null,
546+
'some_value',
547+
'section1/group1/field1',
548548
false,
549549
'some_value',
550550
null,
551-
1,
551+
0,
552552
false,
553553
false,
554554
false
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\ConfigurableProduct\Model\ResourceModel\Product;
7+
8+
use Magento\Catalog\Model\ResourceModel\Product\BaseSelectProcessorInterface;
9+
use Magento\Catalog\Model\ResourceModel\Product\LinkedProductSelectBuilderInterface;
10+
11+
/**
12+
* A decorator for a linked product select builder.
13+
*
14+
* Extends functionality of the linked product select builder to allow perform
15+
* some additional processing of built Select objects.
16+
*/
17+
class LinkedProductSelectBuilder implements LinkedProductSelectBuilderInterface
18+
{
19+
/**
20+
* @var BaseSelectProcessorInterface
21+
*/
22+
private $baseSelectProcessor;
23+
24+
/**
25+
* @var LinkedProductSelectBuilderInterface
26+
*/
27+
private $linkedProductSelectBuilder;
28+
29+
/**
30+
* @param BaseSelectProcessorInterface $baseSelectProcessor
31+
* @param LinkedProductSelectBuilderInterface $linkedProductSelectBuilder
32+
*/
33+
public function __construct(
34+
BaseSelectProcessorInterface $baseSelectProcessor,
35+
LinkedProductSelectBuilderInterface $linkedProductSelectBuilder
36+
) {
37+
$this->baseSelectProcessor = $baseSelectProcessor;
38+
$this->linkedProductSelectBuilder = $linkedProductSelectBuilder;
39+
}
40+
41+
/**
42+
* {@inheritdoc}
43+
*/
44+
public function build($productId)
45+
{
46+
$selects = $this->linkedProductSelectBuilder->build($productId);
47+
48+
foreach ($selects as $select) {
49+
$this->baseSelectProcessor->process($select);
50+
}
51+
52+
return $selects;
53+
}
54+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\ConfigurableProduct\Model\ResourceModel\Product;
7+
8+
use Magento\Framework\DB\Select;
9+
use Magento\Catalog\Model\ResourceModel\Product\BaseSelectProcessorInterface;
10+
use Magento\CatalogInventory\Api\StockConfigurationInterface;
11+
use Magento\CatalogInventory\Model\Stock\Status as StockStatus;
12+
use Magento\CatalogInventory\Model\ResourceModel\Stock\Status as StockStatusResource;
13+
14+
/**
15+
* A Select object processor.
16+
*
17+
* Adds stock status limitations to a given Select object.
18+
*/
19+
class StockStatusBaseSelectProcessor implements BaseSelectProcessorInterface
20+
{
21+
/**
22+
* @var StockConfigurationInterface
23+
*/
24+
private $stockConfig;
25+
26+
/**
27+
* @var StockStatusResource
28+
*/
29+
private $stockStatusResource;
30+
31+
/**
32+
* @param StockConfigurationInterface $stockConfig
33+
* @param StockStatusResource $stockStatusResource
34+
*/
35+
public function __construct(
36+
StockConfigurationInterface $stockConfig,
37+
StockStatusResource $stockStatusResource
38+
) {
39+
$this->stockConfig = $stockConfig;
40+
$this->stockStatusResource = $stockStatusResource;
41+
}
42+
43+
/**
44+
* {@inheritdoc}
45+
*/
46+
public function process(Select $select)
47+
{
48+
if ($this->stockConfig->isShowOutOfStock()) {
49+
$select->joinInner(
50+
['stock' => $this->stockStatusResource->getMainTable()],
51+
sprintf(
52+
'stock.product_id = %s.entity_id',
53+
BaseSelectProcessorInterface::PRODUCT_TABLE_ALIAS
54+
),
55+
[]
56+
)->where(
57+
'stock.stock_status = ?',
58+
StockStatus::STATUS_IN_STOCK
59+
);
60+
}
61+
62+
return $select;
63+
}
64+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\ConfigurableProduct\Plugin\Catalog\Model\Product\Pricing\Renderer;
7+
8+
use Magento\ConfigurableProduct\Pricing\Price\LowestPriceOptionsProviderInterface;
9+
10+
/**
11+
* A plugin for a salable resolver.
12+
*/
13+
class SalableResolver
14+
{
15+
/**
16+
* @var LowestPriceOptionsProviderInterface
17+
*/
18+
private $lowestPriceOptionsProvider;
19+
20+
/**
21+
* @param LowestPriceOptionsProviderInterface $lowestPriceOptionsProvider
22+
*/
23+
public function __construct(
24+
LowestPriceOptionsProviderInterface $lowestPriceOptionsProvider
25+
) {
26+
$this->lowestPriceOptionsProvider = $lowestPriceOptionsProvider;
27+
}
28+
29+
/**
30+
* Performs an additional check whether given configurable product has
31+
* at least one configuration in-stock.
32+
*
33+
* @param \Magento\Catalog\Model\Product\Pricing\Renderer\SalableResolver $subject
34+
* @param bool $result
35+
* @param \Magento\Framework\Pricing\SaleableInterface $salableItem
36+
*
37+
* @return bool
38+
*
39+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
40+
*/
41+
public function afterIsSalable(
42+
\Magento\Catalog\Model\Product\Pricing\Renderer\SalableResolver $subject,
43+
$result,
44+
\Magento\Framework\Pricing\SaleableInterface $salableItem
45+
) {
46+
if ($salableItem->getTypeId() == 'configurable' && $result) {
47+
if (!$this->lowestPriceOptionsProvider->getProducts($salableItem)) {
48+
$result = false;
49+
}
50+
}
51+
52+
return $result;
53+
}
54+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\ConfigurableProduct\Test\Unit\Model\ResourceModel\Product;
7+
8+
use Magento\Framework\DB\Select;
9+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
10+
use Magento\Catalog\Model\ResourceModel\Product\BaseSelectProcessorInterface;
11+
use Magento\Catalog\Model\ResourceModel\Product\LinkedProductSelectBuilderInterface;
12+
use Magento\ConfigurableProduct\Model\ResourceModel\Product\LinkedProductSelectBuilder;
13+
14+
class LinkedProductSelectBuilderTest extends \PHPUnit\Framework\TestCase
15+
{
16+
/**
17+
* @var LinkedProductSelectBuilder
18+
*/
19+
private $subject;
20+
21+
/**
22+
* @var BaseSelectProcessorInterface|\PHPUnit_Framework_MockObject_MockObject
23+
*/
24+
private $baseSelectProcessorMock;
25+
26+
/**
27+
* @var LinkedProductSelectBuilderInterface|\PHPUnit_Framework_MockObject_MockObject
28+
*/
29+
private $linkedProductSelectBuilderMock;
30+
31+
protected function setUp()
32+
{
33+
$this->baseSelectProcessorMock = $this->getMockBuilder(BaseSelectProcessorInterface::class)
34+
->disableOriginalConstructor()
35+
->getMockForAbstractClass();
36+
37+
$this->linkedProductSelectBuilderMock = $this->getMockBuilder(LinkedProductSelectBuilderInterface::class)
38+
->disableOriginalConstructor()
39+
->getMockForAbstractClass();
40+
41+
$this->subject = (new ObjectManager($this))->getObject(
42+
LinkedProductSelectBuilder::class,
43+
[
44+
'baseSelectProcessor' => $this->baseSelectProcessorMock,
45+
'linkedProductSelectBuilder' => $this->linkedProductSelectBuilderMock
46+
]
47+
);
48+
}
49+
50+
public function testBuild()
51+
{
52+
$productId = 42;
53+
54+
/** @var Select|\PHPUnit_Framework_MockObject_MockObject $selectMock */
55+
$selectMock = $this->getMockBuilder(Select::class)
56+
->disableOriginalConstructor()
57+
->getMock();
58+
59+
$expectedResult = [$selectMock];
60+
61+
$this->linkedProductSelectBuilderMock->expects($this->any())
62+
->method('build')
63+
->with($productId)
64+
->willReturn($expectedResult);
65+
66+
$this->baseSelectProcessorMock->expects($this->once())
67+
->method('process')
68+
->with($selectMock);
69+
70+
$this->assertEquals($expectedResult, $this->subject->build($productId));
71+
}
72+
}

0 commit comments

Comments
 (0)