From 60a16473e291ab96be827a8a324538aeaae54be4 Mon Sep 17 00:00:00 2001 From: Leonid Poluyanov Date: Mon, 22 Aug 2016 13:30:05 +0300 Subject: [PATCH] MAGETWO-52161: [GitHub] Bug in EAV with group_price attribute #69 --- src/Migration/Step/Eav/Data.php | 2 +- src/Migration/Step/Eav/InitialData.php | 6 +----- src/Migration/Step/Eav/Volume.php | 2 +- tests/unit/testsuite/Migration/Step/Eav/InitialDataTest.php | 2 +- tests/unit/testsuite/Migration/Step/Eav/VolumeTest.php | 4 +++- 5 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/Migration/Step/Eav/Data.php b/src/Migration/Step/Eav/Data.php index a0fbcf1ed..65576e98e 100644 --- a/src/Migration/Step/Eav/Data.php +++ b/src/Migration/Step/Eav/Data.php @@ -383,7 +383,7 @@ protected function migrateAttributes() $this->map->getDocumentMap($sourceDocName, MapInterface::TYPE_SOURCE) ); $this->destination->backupDocument($destinationDocument->getName()); - $sourceRecords = $this->initialData->getAttributes('source');; + $sourceRecords = $this->helper->clearIgnored($this->initialData->getAttributes('source')); $destinationRecords = $this->initialData->getAttributes('dest'); $recordsToSave = $destinationDocument->getRecords(); diff --git a/src/Migration/Step/Eav/InitialData.php b/src/Migration/Step/Eav/InitialData.php index 280740f5d..c16f8ce72 100644 --- a/src/Migration/Step/Eav/InitialData.php +++ b/src/Migration/Step/Eav/InitialData.php @@ -106,11 +106,7 @@ protected function initAttributes() if ($this->attributes === null) { $sourceDocument = 'eav_attribute'; - foreach ( - $this->helper->clearIgnored( - $this->helper->getSourceRecords($sourceDocument, ['attribute_id']) - ) as $id => $record - ) { + foreach ($this->helper->getSourceRecords($sourceDocument, ['attribute_id']) as $id => $record) { $this->attributes['source'][$id] = $record; } diff --git a/src/Migration/Step/Eav/Volume.php b/src/Migration/Step/Eav/Volume.php index ba1ba5a0f..2a35d2c21 100644 --- a/src/Migration/Step/Eav/Volume.php +++ b/src/Migration/Step/Eav/Volume.php @@ -178,7 +178,7 @@ protected function validateCustomConditions(array $attribute, array $conditions) */ protected function checkAttributesMismatch($attribute) { - $sourceAttributes = $this->initialData->getAttributes('source'); + $sourceAttributes = $this->helper->clearIgnored($this->initialData->getAttributes('source')); if (isset($sourceAttributes[$attribute['attribute_id']]) && ($sourceAttributes[$attribute['attribute_id']]['attribute_code'] != $attribute['attribute_code']) diff --git a/tests/unit/testsuite/Migration/Step/Eav/InitialDataTest.php b/tests/unit/testsuite/Migration/Step/Eav/InitialDataTest.php index 921bc1c2d..bb3bfc99c 100644 --- a/tests/unit/testsuite/Migration/Step/Eav/InitialDataTest.php +++ b/tests/unit/testsuite/Migration/Step/Eav/InitialDataTest.php @@ -55,7 +55,7 @@ public function setUp() ->setMethods([]) ->getMock(); $this->helper = $this->getMockBuilder('\Migration\Step\Eav\Helper')->disableOriginalConstructor() - ->setMethods(['getSourceRecords', 'getDestinationRecords', 'clearIgnored']) + ->setMethods(['getSourceRecords', 'getDestinationRecords']) ->getMock(); $this->initialData = new InitialData($mapFactory, $this->source, $this->destination, $this->helper); } diff --git a/tests/unit/testsuite/Migration/Step/Eav/VolumeTest.php b/tests/unit/testsuite/Migration/Step/Eav/VolumeTest.php index 1abe64ea4..d899a7e5b 100644 --- a/tests/unit/testsuite/Migration/Step/Eav/VolumeTest.php +++ b/tests/unit/testsuite/Migration/Step/Eav/VolumeTest.php @@ -59,7 +59,8 @@ public function setUp() 'getDestinationRecords', 'getSourceRecordsCount', 'getDestinationRecordsCount', - 'deleteBackups' + 'deleteBackups', + 'clearIgnored' ] )->getMock(); $this->logger = $this->getMockBuilder('\Migration\Logger\Logger')->disableOriginalConstructor() @@ -153,6 +154,7 @@ public function testPerform() $this->initialData->expects($this->once())->method('getAttributeGroups')->willReturn(1); $this->helper->expects($this->any())->method('getDestinationRecordsCount')->willReturn(2); $this->helper->expects($this->once())->method('deleteBackups'); + $this->helper->expects($this->any())->method('clearIgnored')->with($eavAttributes)->willReturn($eavAttributes); $this->logger->expects($this->never())->method('addRecord'); $documentsMap = $this->getDocumentsMap();