Skip to content

Commit 1505a44

Browse files
committed
MAGETWO-62691: [Performance] EAV attributes caching optimization
1 parent 36f204b commit 1505a44

File tree

4 files changed

+8
-26
lines changed

4 files changed

+8
-26
lines changed

app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -707,25 +707,13 @@ public function testDeleteById()
707707
public function testGetList()
708708
{
709709
$searchCriteriaMock = $this->getMock(\Magento\Framework\Api\SearchCriteriaInterface::class, [], [], '', false);
710-
$attributeCode = 'attribute_code';
711710
$collectionMock = $this->getMock(
712711
\Magento\Catalog\Model\ResourceModel\Product\Collection::class,
713712
[],
714713
[],
715714
'',
716715
false
717716
);
718-
$productAttributeSearchResultsMock = $this->getMockBuilder(ProductAttributeInterface::class)
719-
->disableOriginalConstructor()
720-
->setMethods(['getItems'])
721-
->getMockForAbstractClass();
722-
$productAttributeMock = $this->getMock(
723-
\Magento\Catalog\Api\Data\ProductAttributeInterface::class,
724-
[],
725-
[],
726-
'',
727-
false
728-
);
729717

730718
$this->collectionFactoryMock->expects($this->once())->method('create')->willReturn($collectionMock);
731719

app/code/Magento/Eav/Model/Config.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -543,11 +543,9 @@ private function createAttribute($model)
543543
* @deprecated
544544
* @see \Magento\Eav\Model\Config::getEntityAttributes
545545
*
546-
* @param mixed $entityType
547-
* @param \Magento\Framework\DataObject $object
546+
* @param mixed $entityType
547+
* @param \Magento\Framework\DataObject $object
548548
* @return string[]
549-
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
550-
* @SuppressWarnings(PHPMD.NPathComplexity)
551549
*/
552550
public function getEntityAttributeCodes($entityType, $object = null)
553551
{
@@ -560,6 +558,9 @@ public function getEntityAttributeCodes($entityType, $object = null)
560558
* @param int|string|Type $entityType
561559
* @param \Magento\Framework\DataObject|null $object
562560
* @return AbstractAttribute[]
561+
*
562+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
563+
* @SuppressWarnings(PHPMD.NPathComplexity)
563564
*/
564565
public function getEntityAttributes($entityType, $object = null)
565566
{

app/code/Magento/Eav/Test/Unit/Model/ConfigTest.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,7 @@ protected function setUp()
8787
);
8888
}
8989

90-
/**
91-
* @param boolean $cacheEnabled
92-
* @param int $loadCalls
93-
* @param int $cachedValue
94-
* @param int $unserializeCalls
95-
* @dataProvider getAttributeCacheDataProvider
96-
* @return void
97-
*/
98-
public function testGetAttributeCache($cacheEnabled, $loadCalls, $unserializeCalls, $cachedValue)
90+
public function testGetAttributeCache()
9991
{
10092
$attributeData = [
10193
'attribute_code' => 'attribute_code_1',
@@ -201,7 +193,7 @@ public function getAttributeCacheDataProvider()
201193
* @dataProvider getAttributeCacheDataProvider
202194
* @return void
203195
*/
204-
public function testGetAttributes($cacheEnabled, $loadCalls, $unserializeCalls, $cachedValue)
196+
public function testGetAttributes($cacheEnabled)
205197
{
206198
$attributeData = [
207199
'attribute_code' => 'attribute_code_1',

app/code/Magento/Swatches/Helper/Data.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,7 @@ public function getSwatchAttributesAsArray(Product $product)
429429
*/
430430
public function getSwatchesByOptionsId(array $optionIds)
431431
{
432+
sort($optionIds);
432433
$cacheKey = implode('-', $optionIds);
433434
if (!isset($this->swatchesCache[$cacheKey])) {
434435
/** @var \Magento\Swatches\Model\ResourceModel\Swatch\Collection $swatchCollection */

0 commit comments

Comments
 (0)