Skip to content

Commit

Permalink
Merge pull request #1573 from magento-panda/2.2-stabilization
Browse files Browse the repository at this point in the history
[KoKoC] 2.2-develop stabilization + cumulative PR merge
  • Loading branch information
viktym authored Oct 10, 2017
2 parents d30f077 + dfd934f commit cc71ccf
Show file tree
Hide file tree
Showing 34 changed files with 25,437 additions and 6,766 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ protected function modifyPriceData($object, $data)
{
/** @var array $priceItem */
foreach ($data as $key => $priceItem) {
if (isset($priceItem['price']) && $priceItem['price'] > 0) {
if (array_key_exists('price', $priceItem)) {
$data[$key]['website_price'] = $priceItem['price'];
}
if ($priceItem['all_groups']) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class IndexTableRowSizeEstimator implements \Magento\Framework\Indexer\IndexTabl
/**
* Calculated memory size for one record in catalog_product_index_price table
*/
const MEMORY_SIZE_FOR_ONE_ROW = 120;
const MEMORY_SIZE_FOR_ONE_ROW = 200;

/**
* @var \Magento\Store\Api\WebsiteManagementInterface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ public function testSetPriceData()
{
$attributeName = 'tier_price';
$tierPrices = [
[
'price' => 0,
'all_groups' => 1,
],
[
'price' => 10,
'all_groups' => 1,
Expand All @@ -153,6 +157,12 @@ public function testSetPriceData()
$productPrice = 20;
$allCustomersGroupId = 32000;
$finalTierPrices = [
[
'price' => 0,
'all_groups' => 1,
'website_price' => 0,
'cust_group' => 32000,
],
[
'price' => 10,
'all_groups' => 1,
Expand All @@ -170,8 +180,11 @@ public function testSetPriceData()
->disableOriginalConstructor()->getMock();
$allCustomersGroup = $this->getMockBuilder(\Magento\Customer\Api\Data\GroupInterface::class)
->disableOriginalConstructor()->getMock();
$this->groupManagement->expects($this->once())->method('getAllCustomersGroup')->willReturn($allCustomersGroup);
$allCustomersGroup->expects($this->once())->method('getId')->willReturn($allCustomersGroupId);
$this->groupManagement
->expects($this->exactly(2))
->method('getAllCustomersGroup')
->willReturn($allCustomersGroup);
$allCustomersGroup->expects($this->exactly(2))->method('getId')->willReturn($allCustomersGroupId);
$object->expects($this->once())->method('getPrice')->willReturn($productPrice);
$this->attribute->expects($this->atLeastOnce())->method('isScopeGlobal')->willReturn(true);
$object->expects($this->once())->method('getStoreId')->willReturn(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected function setUp()

public function testEstimateRowSize()
{
$expectedValue = 2400000;
$expectedValue = 4000000;

$this->websiteManagementMock->expects($this->once())->method('getCount')->willReturn(100);
$collectionMock = $this->createMock(\Magento\Customer\Model\ResourceModel\Group\Collection::class);
Expand Down
20 changes: 3 additions & 17 deletions app/code/Magento/Config/Block/System/Config/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -425,24 +425,10 @@ private function getFieldData(\Magento\Config\Model\Config\Structure\Element\Fie
if ($placeholderValue) {
$data = $placeholderValue;
}

if ($data === null) {
if (array_key_exists($path, $this->_configData)) {
$data = $this->_configData[$path];

if ($field->hasBackendModel()) {
$backendModel = $field->getBackendModel();
$backendModel->setPath($path)
->setValue($data)
->setWebsite($this->getWebsiteCode())
->setStore($this->getStoreCode())
->afterLoad();
$data = $backendModel->getValue();
}
} elseif ($field->getConfigPath() !== null) {
$data = $this->getConfigValue($field->getConfigPath());
} else {
$data = $this->getConfigValue($path);
}
$path = $field->getConfigPath() !== null ? $field->getConfigPath() : $path;
$data = $this->getConfigValue($path);
}

return $data;
Expand Down
11 changes: 10 additions & 1 deletion app/code/Magento/Config/Model/Config/Backend/Serialized.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
*/
namespace Magento\Config\Model\Config\Backend;

use Magento\Framework\App\Config\Data\ProcessorInterface;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Serialize\Serializer\Json;

/**
* @api
* @since 100.0.2
*/
class Serialized extends \Magento\Framework\App\Config\Value
class Serialized extends \Magento\Framework\App\Config\Value implements ProcessorInterface
{
/**
* @var Json
Expand Down Expand Up @@ -67,4 +68,12 @@ public function beforeSave()
parent::beforeSave();
return $this;
}

/**
* @inheritdoc
*/
public function processValue($value)
{
return empty($value) ? '' : $this->serializer->unserialize($value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -543,12 +543,12 @@ public function initFieldsDataProvider()
return [
[
['section1/group1/field1' => 'some_value'],
false,
null,
'some_value',
'section1/group1/field1',
false,
'some_value',
null,
1,
0,
false,
false,
false
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\ConfigurableProduct\Model\ResourceModel\Product;

use Magento\Catalog\Model\ResourceModel\Product\BaseSelectProcessorInterface;
use Magento\Catalog\Model\ResourceModel\Product\LinkedProductSelectBuilderInterface;

/**
* A decorator for a linked product select builder.
*
* Extends functionality of the linked product select builder to allow perform
* some additional processing of built Select objects.
*/
class LinkedProductSelectBuilder implements LinkedProductSelectBuilderInterface
{
/**
* @var BaseSelectProcessorInterface
*/
private $baseSelectProcessor;

/**
* @var LinkedProductSelectBuilderInterface
*/
private $linkedProductSelectBuilder;

/**
* @param BaseSelectProcessorInterface $baseSelectProcessor
* @param LinkedProductSelectBuilderInterface $linkedProductSelectBuilder
*/
public function __construct(
BaseSelectProcessorInterface $baseSelectProcessor,
LinkedProductSelectBuilderInterface $linkedProductSelectBuilder
) {
$this->baseSelectProcessor = $baseSelectProcessor;
$this->linkedProductSelectBuilder = $linkedProductSelectBuilder;
}

/**
* {@inheritdoc}
*/
public function build($productId)
{
$selects = $this->linkedProductSelectBuilder->build($productId);

foreach ($selects as $select) {
$this->baseSelectProcessor->process($select);
}

return $selects;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\ConfigurableProduct\Model\ResourceModel\Product;

use Magento\Framework\DB\Select;
use Magento\Catalog\Model\ResourceModel\Product\BaseSelectProcessorInterface;
use Magento\CatalogInventory\Api\StockConfigurationInterface;
use Magento\CatalogInventory\Model\Stock\Status as StockStatus;
use Magento\CatalogInventory\Model\ResourceModel\Stock\Status as StockStatusResource;

/**
* A Select object processor.
*
* Adds stock status limitations to a given Select object.
*/
class StockStatusBaseSelectProcessor implements BaseSelectProcessorInterface
{
/**
* @var StockConfigurationInterface
*/
private $stockConfig;

/**
* @var StockStatusResource
*/
private $stockStatusResource;

/**
* @param StockConfigurationInterface $stockConfig
* @param StockStatusResource $stockStatusResource
*/
public function __construct(
StockConfigurationInterface $stockConfig,
StockStatusResource $stockStatusResource
) {
$this->stockConfig = $stockConfig;
$this->stockStatusResource = $stockStatusResource;
}

/**
* {@inheritdoc}
*/
public function process(Select $select)
{
if ($this->stockConfig->isShowOutOfStock()) {
$select->joinInner(
['stock' => $this->stockStatusResource->getMainTable()],
sprintf(
'stock.product_id = %s.entity_id',
BaseSelectProcessorInterface::PRODUCT_TABLE_ALIAS
),
[]
)->where(
'stock.stock_status = ?',
StockStatus::STATUS_IN_STOCK
);
}

return $select;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\ConfigurableProduct\Plugin\Catalog\Model\Product\Pricing\Renderer;

use Magento\ConfigurableProduct\Pricing\Price\LowestPriceOptionsProviderInterface;

/**
* A plugin for a salable resolver.
*/
class SalableResolver
{
/**
* @var LowestPriceOptionsProviderInterface
*/
private $lowestPriceOptionsProvider;

/**
* @param LowestPriceOptionsProviderInterface $lowestPriceOptionsProvider
*/
public function __construct(
LowestPriceOptionsProviderInterface $lowestPriceOptionsProvider
) {
$this->lowestPriceOptionsProvider = $lowestPriceOptionsProvider;
}

/**
* Performs an additional check whether given configurable product has
* at least one configuration in-stock.
*
* @param \Magento\Catalog\Model\Product\Pricing\Renderer\SalableResolver $subject
* @param bool $result
* @param \Magento\Framework\Pricing\SaleableInterface $salableItem
*
* @return bool
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function afterIsSalable(
\Magento\Catalog\Model\Product\Pricing\Renderer\SalableResolver $subject,
$result,
\Magento\Framework\Pricing\SaleableInterface $salableItem
) {
if ($salableItem->getTypeId() == 'configurable' && $result) {
if (!$this->lowestPriceOptionsProvider->getProducts($salableItem)) {
$result = false;
}
}

return $result;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\ConfigurableProduct\Test\Unit\Model\ResourceModel\Product;

use Magento\Framework\DB\Select;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Catalog\Model\ResourceModel\Product\BaseSelectProcessorInterface;
use Magento\Catalog\Model\ResourceModel\Product\LinkedProductSelectBuilderInterface;
use Magento\ConfigurableProduct\Model\ResourceModel\Product\LinkedProductSelectBuilder;

class LinkedProductSelectBuilderTest extends \PHPUnit\Framework\TestCase
{
/**
* @var LinkedProductSelectBuilder
*/
private $subject;

/**
* @var BaseSelectProcessorInterface|\PHPUnit_Framework_MockObject_MockObject
*/
private $baseSelectProcessorMock;

/**
* @var LinkedProductSelectBuilderInterface|\PHPUnit_Framework_MockObject_MockObject
*/
private $linkedProductSelectBuilderMock;

protected function setUp()
{
$this->baseSelectProcessorMock = $this->getMockBuilder(BaseSelectProcessorInterface::class)
->disableOriginalConstructor()
->getMockForAbstractClass();

$this->linkedProductSelectBuilderMock = $this->getMockBuilder(LinkedProductSelectBuilderInterface::class)
->disableOriginalConstructor()
->getMockForAbstractClass();

$this->subject = (new ObjectManager($this))->getObject(
LinkedProductSelectBuilder::class,
[
'baseSelectProcessor' => $this->baseSelectProcessorMock,
'linkedProductSelectBuilder' => $this->linkedProductSelectBuilderMock
]
);
}

public function testBuild()
{
$productId = 42;

/** @var Select|\PHPUnit_Framework_MockObject_MockObject $selectMock */
$selectMock = $this->getMockBuilder(Select::class)
->disableOriginalConstructor()
->getMock();

$expectedResult = [$selectMock];

$this->linkedProductSelectBuilderMock->expects($this->any())
->method('build')
->with($productId)
->willReturn($expectedResult);

$this->baseSelectProcessorMock->expects($this->once())
->method('process')
->with($selectMock);

$this->assertEquals($expectedResult, $this->subject->build($productId));
}
}
Loading

0 comments on commit cc71ccf

Please sign in to comment.