-
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 #1409 from magento-plankton/2.2-bugs
Bugs - MAGETWO-71030 Sound from video from parent configurable product plays when start play video of child - MAGETWO-71373 Cannot install EE without Staging modules - MAGETWO-71242 Indexing fails on b2b medium profile
- Loading branch information
Showing
16 changed files
with
327 additions
and
63 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
35 changes: 35 additions & 0 deletions
35
...o/Catalog/Model/ResourceModel/Product/Indexer/Price/CompositeProductBatchSizeAdjuster.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,35 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Magento\Catalog\Model\ResourceModel\Product\Indexer\Price; | ||
|
||
/** | ||
* Correct batch size according to number of composite related items. | ||
*/ | ||
class CompositeProductBatchSizeAdjuster implements CompositeProductBatchSizeAdjusterInterface | ||
{ | ||
/** | ||
* @var CompositeProductRelationsCalculator | ||
*/ | ||
private $compositeProductRelationsCalculator; | ||
|
||
/** | ||
* @param CompositeProductRelationsCalculator $compositeProductRelationsCalculator | ||
*/ | ||
public function __construct(CompositeProductRelationsCalculator $compositeProductRelationsCalculator) | ||
{ | ||
$this->compositeProductRelationsCalculator = $compositeProductRelationsCalculator; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function adjust($batchSize) | ||
{ | ||
$maxRelationsCount = $this->compositeProductRelationsCalculator->getMaxRelationsCount(); | ||
return $maxRelationsCount > 0 ? ceil($batchSize / $maxRelationsCount) : $batchSize; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
.../Model/ResourceModel/Product/Indexer/Price/CompositeProductBatchSizeAdjusterInterface.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,22 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Magento\Catalog\Model\ResourceModel\Product\Indexer\Price; | ||
|
||
/** | ||
* Correct batch size according to number of composite related items. | ||
* @api | ||
*/ | ||
interface CompositeProductBatchSizeAdjusterInterface | ||
{ | ||
/** | ||
* Correct batch size according to number of composite related items. | ||
* | ||
* @param int $batchSize | ||
* @return int | ||
*/ | ||
public function adjust($batchSize); | ||
} |
44 changes: 44 additions & 0 deletions
44
...Catalog/Model/ResourceModel/Product/Indexer/Price/CompositeProductRelationsCalculator.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,44 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Magento\Catalog\Model\ResourceModel\Product\Indexer\Price; | ||
|
||
/** | ||
* Class calculates composite product relations. | ||
*/ | ||
class CompositeProductRelationsCalculator | ||
{ | ||
/** | ||
* @param DefaultPrice $indexerResource | ||
*/ | ||
public function __construct(DefaultPrice $indexerResource) | ||
{ | ||
$this->indexerResource = $indexerResource; | ||
} | ||
|
||
/** | ||
* Returns maximum number of composite related products. | ||
* | ||
* @return int | ||
*/ | ||
public function getMaxRelationsCount() | ||
{ | ||
$connection = $this->indexerResource->getConnection(); | ||
$relationSelect = $connection->select(); | ||
$relationSelect->from( | ||
['relation' => $this->indexerResource->getTable('catalog_product_relation')], | ||
['count' => new \Zend_Db_Expr('count(relation.child_id)')] | ||
); | ||
$relationSelect->group('parent_id'); | ||
|
||
$maxSelect = $connection->select(); | ||
$maxSelect->from( | ||
['max_value' => $relationSelect], | ||
['count' => new \Zend_Db_Expr('MAX(count)')] | ||
); | ||
return $connection->fetchOne($maxSelect); | ||
} | ||
} |
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
39 changes: 39 additions & 0 deletions
39
.../Unit/Model/ResourceModel/Product/Indexer/Price/CompositeProductBatchSizeAdjusterTest.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,39 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Magento\Catalog\Test\Unit\Model\ResourceModel\Product\Indexer\Price; | ||
|
||
use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\CompositeProductBatchSizeAdjuster; | ||
use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\CompositeProductRelationsCalculator; | ||
|
||
class CompositeProductBatchSizeAdjusterTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
/** | ||
* @var CompositeProductBatchSizeAdjuster | ||
*/ | ||
private $model; | ||
|
||
/** | ||
* @var \PHPUnit_Framework_MockObject_MockObject|CompositeProductRelationsCalculator | ||
*/ | ||
private $relationsCalculatorMock; | ||
|
||
protected function setUp() | ||
{ | ||
$this->relationsCalculatorMock = $this->getMockBuilder(CompositeProductRelationsCalculator::class) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
$this->model = new CompositeProductBatchSizeAdjuster($this->relationsCalculatorMock); | ||
} | ||
|
||
public function testAdjust() | ||
{ | ||
$this->relationsCalculatorMock->expects($this->once()) | ||
->method('getMaxRelationsCount') | ||
->willReturn(200); | ||
$this->assertEquals(25, $this->model->adjust(5000)); | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
...nit/Model/ResourceModel/Product/Indexer/Price/CompositeProductRelationsCalculatorTest.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,71 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Magento\Catalog\Test\Unit\Model\ResourceModel\Product\Indexer\Price; | ||
|
||
use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\DefaultPrice; | ||
use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\CompositeProductRelationsCalculator; | ||
|
||
class CompositeProductRelationsCalculatorTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
/** | ||
* @var \PHPUnit_Framework_MockObject_MockObject|DefaultPrice | ||
*/ | ||
private $defaultPriceMock; | ||
|
||
/** | ||
* @var CompositeProductRelationsCalculator | ||
*/ | ||
private $model; | ||
|
||
protected function setUp() | ||
{ | ||
$this->defaultPriceMock = $this->getMockBuilder(DefaultPrice::class)->disableOriginalConstructor()->getMock(); | ||
$this->model = new CompositeProductRelationsCalculator($this->defaultPriceMock); | ||
} | ||
|
||
public function testGetMaxRelationsCount() | ||
{ | ||
$tableName = 'catalog_product_relation'; | ||
$maxRelatedProductCount = 200; | ||
|
||
$connectionMock = $this->getMockBuilder(\Magento\Framework\DB\Adapter\AdapterInterface::class)->getMock(); | ||
$this->defaultPriceMock->expects($this->once())->method('getConnection')->willReturn($connectionMock); | ||
$this->defaultPriceMock->expects($this->once())->method('getTable')->with($tableName)->willReturn($tableName); | ||
|
||
$relationSelectMock = $this->getMockBuilder(\Magento\Framework\DB\Select::class) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
$relationSelectMock->expects($this->once()) | ||
->method('from') | ||
->with( | ||
['relation' => $tableName], | ||
['count' => 'count(relation.child_id)'] | ||
) | ||
->willReturnSelf(); | ||
$relationSelectMock->expects($this->once())->method('group')->with('parent_id')->willReturnSelf(); | ||
$connectionMock->expects($this->at(0))->method('select')->willReturn($relationSelectMock); | ||
|
||
$maxSelectMock = $this->getMockBuilder(\Magento\Framework\DB\Select::class) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
$maxSelectMock->expects($this->once()) | ||
->method('from') | ||
->with( | ||
['max_value' => $relationSelectMock], | ||
['count' => 'MAX(count)'] | ||
) | ||
->willReturnSelf(); | ||
$connectionMock->expects($this->at(1))->method('select')->willReturn($maxSelectMock); | ||
|
||
$connectionMock->expects($this->at(2)) | ||
->method('fetchOne') | ||
->with($maxSelectMock) | ||
->willReturn($maxRelatedProductCount); | ||
|
||
$this->assertEquals($maxRelatedProductCount, $this->model->getMaxRelationsCount()); | ||
} | ||
} |
Oops, something went wrong.