-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1573 from magento-panda/2.2-stabilization
[KoKoC] 2.2-develop stabilization + cumulative PR merge
- Loading branch information
Showing
34 changed files
with
25,437 additions
and
6,766 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...de/Magento/ConfigurableProduct/Model/ResourceModel/Product/LinkedProductSelectBuilder.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
...agento/ConfigurableProduct/Model/ResourceModel/Product/StockStatusBaseSelectProcessor.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
...nto/ConfigurableProduct/Plugin/Catalog/Model/Product/Pricing/Renderer/SalableResolver.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
...figurableProduct/Test/Unit/Model/ResourceModel/Product/LinkedProductSelectBuilderTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
} |
Oops, something went wrong.