-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MAGETWO-95789: [GitHub] Error in system.log about migrated attribute …
…which is not included into attribute group #598
- Loading branch information
1 parent
a280dc2
commit c5d7b65
Showing
10 changed files
with
339 additions
and
23 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
84 changes: 84 additions & 0 deletions
84
src/Migration/Step/PostProcessing/Data/AttributeSetLeftoverDataCleaner.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,84 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Migration\Step\PostProcessing\Data; | ||
|
||
use Migration\ResourceModel; | ||
use Migration\App\ProgressBar; | ||
use Migration\App\Progress; | ||
use Migration\Logger\Manager as LogManager; | ||
use \Migration\Step\PostProcessing\Model\AttributeSetLeftoverData as AttributeSetLeftoverDataModel; | ||
|
||
/** | ||
* Class AttributeSetLeftoverDataCleaner | ||
*/ | ||
class AttributeSetLeftoverDataCleaner | ||
{ | ||
/** | ||
* @var ResourceModel\Destination | ||
*/ | ||
private $destination; | ||
|
||
/** | ||
* @var ProgressBar\LogLevelProcessor | ||
*/ | ||
private $progressBar; | ||
|
||
/** | ||
* @var Progress | ||
*/ | ||
private $progress; | ||
|
||
/** | ||
* @var AttributeSetLeftoverDataModel | ||
*/ | ||
private $attributeSetLeftoverDataModel; | ||
|
||
/** | ||
* @param ProgressBar\LogLevelProcessor $progressBar | ||
* @param ResourceModel\Destination $destination | ||
* @param Progress $progress | ||
* @param AttributeSetLeftoverDataModel $attributeSetLeftoverDataModel | ||
*/ | ||
public function __construct( | ||
ProgressBar\LogLevelProcessor $progressBar, | ||
ResourceModel\Destination $destination, | ||
Progress $progress, | ||
AttributeSetLeftoverDataModel $attributeSetLeftoverDataModel | ||
) { | ||
$this->destination = $destination; | ||
$this->progressBar = $progressBar; | ||
$this->progress = $progress; | ||
$this->attributeSetLeftoverDataModel = $attributeSetLeftoverDataModel; | ||
} | ||
|
||
/** | ||
* Records which are still in product entity tables | ||
* but product attribute no longer exist in attribute set | ||
*/ | ||
public function clean() | ||
{ | ||
$entityValueIds = $this->attributeSetLeftoverDataModel->getLeftoverIds(); | ||
if (!$entityValueIds) { | ||
return ; | ||
} | ||
foreach ($this->attributeSetLeftoverDataModel->getDocuments() as $document) { | ||
$this->progressBar->advance(LogManager::LOG_LEVEL_INFO); | ||
if (isset($entityValueIds[$document]) && $entityValueIds[$document]) { | ||
$this->destination->deleteRecords($document, 'value_id', $entityValueIds[$document]); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Get documents | ||
* | ||
* @return array | ||
*/ | ||
public function getDocuments() | ||
{ | ||
return $this->attributeSetLeftoverDataModel->getDocuments(); | ||
} | ||
} |
81 changes: 81 additions & 0 deletions
81
src/Migration/Step/PostProcessing/Data/DeletedRecordsCounter.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,81 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Migration\Step\PostProcessing\Data; | ||
|
||
use Migration\ResourceModel; | ||
use Migration\App\Progress; | ||
|
||
/** | ||
* Class DeletedRecordsCounter | ||
*/ | ||
class DeletedRecordsCounter | ||
{ | ||
/** | ||
* @var ResourceModel\Destination | ||
*/ | ||
private $destination; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private $documentRecordsCount; | ||
|
||
/** | ||
* @var Progress | ||
*/ | ||
private $progress; | ||
|
||
/** | ||
* @param ResourceModel\Destination $destination | ||
* @param Progress $progress | ||
*/ | ||
public function __construct( | ||
ResourceModel\Destination $destination, | ||
Progress $progress | ||
) { | ||
$this->destination = $destination; | ||
$this->progress = $progress; | ||
} | ||
|
||
/** | ||
* Count records in given documents | ||
* | ||
* @param $documents | ||
*/ | ||
public function count($documents) | ||
{ | ||
$documents = array_unique($documents); | ||
foreach ($documents as $document) { | ||
$recordsCount = $this->destination->getRecordsCount($document); | ||
$this->documentRecordsCount[$document] = $recordsCount; | ||
} | ||
} | ||
|
||
/** | ||
* Compare current amount of records in given documents | ||
* and save number of deleted records | ||
* | ||
* @param $documents | ||
*/ | ||
public function saveDeleted($documents) | ||
{ | ||
$documentsToSave = []; | ||
$documents = array_unique($documents); | ||
foreach ($documents as $document) { | ||
$recordsCount = $this->destination->getRecordsCount($document); | ||
if (isset($this->documentRecordsCount[$document]) | ||
&& $this->documentRecordsCount[$document] > $recordsCount | ||
) { | ||
$documentsToSave[$document] = $this->documentRecordsCount[$document] - $recordsCount; | ||
} | ||
} | ||
$this->progress->saveProcessedEntities( | ||
'PostProcessing', | ||
'deletedDocumentRowsCount', | ||
$documentsToSave | ||
); | ||
} | ||
} |
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
Oops, something went wrong.