-
Notifications
You must be signed in to change notification settings - Fork 15
refactor!: migration logging system #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feature/migration-logging-refactor
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ | |
|
|
||
| namespace Swag\MigrationMagento\Profile\Magento\Converter; | ||
|
|
||
| use Shopware\Core\Content\Category\CategoryDefinition; | ||
| use Shopware\Core\Framework\Context; | ||
| use Shopware\Core\Framework\Log\Package; | ||
| use Swag\MigrationMagento\Migration\Mapping\MagentoMappingServiceInterface; | ||
|
|
@@ -15,6 +16,7 @@ | |
| use SwagMigrationAssistant\Exception\MigrationException; | ||
| use SwagMigrationAssistant\Migration\Converter\ConvertStruct; | ||
| use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; | ||
| use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; | ||
| use SwagMigrationAssistant\Migration\Logging\Log\EmptyNecessaryFieldRunLog; | ||
| use SwagMigrationAssistant\Migration\Logging\LoggingServiceInterface; | ||
| use SwagMigrationAssistant\Migration\Mapping\Lookup\DefaultCmsPageLookup; | ||
|
|
@@ -85,12 +87,7 @@ public function getSourceIdentifier(array $data): string | |
| public function convert(array $data, Context $context, MigrationContextInterface $migrationContext): ConvertStruct | ||
| { | ||
| $this->context = $context; | ||
|
|
||
| $connection = $migrationContext->getConnection(); | ||
| $this->connectionId = ''; | ||
| if ($connection !== null) { | ||
| $this->connectionId = $connection->getId(); | ||
| } | ||
| $this->connectionId = $migrationContext->getConnection()->getId(); | ||
|
|
||
| // Ignore the magento root category | ||
| if (isset($data['parent_id']) && $data['parent_id'] === '0') { | ||
|
|
@@ -104,16 +101,19 @@ public function convert(array $data, Context $context, MigrationContextInterface | |
|
|
||
| return new ConvertStruct(null, $data); | ||
| } | ||
| $rootCategoryMapping = $this->mappingService->getMapping($this->connectionId, MagentoDefaults::ROOT_CATEGORY, $data['parent_id'], $context); | ||
|
|
||
| $rootCategoryMapping = $this->mappingService->getMapping($this->connectionId, MagentoDefaults::ROOT_CATEGORY, $data['parent_id'], $context); | ||
| $fields = $this->checkForEmptyRequiredDataFields($data, self::$requiredDataFieldKeys); | ||
|
|
||
| if (!empty($fields)) { | ||
| $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( | ||
| $migrationContext->getRunUuid(), | ||
| DefaultEntities::CATEGORY, | ||
| $data['entity_id'], | ||
| \implode(',', $fields) | ||
| )); | ||
| $this->loggingService->addLogForEach( | ||
| $fields, | ||
| fn (string $key) => SwagMigrationLogBuilder::fromMigrationContext($migrationContext) | ||
| ->withEntityName(CategoryDefinition::ENTITY_NAME) | ||
| ->withFieldSourcePath($key) | ||
| ->withSourceData($data) | ||
| ->build(EmptyNecessaryFieldRunLog::class) | ||
|
Comment on lines
+109
to
+115
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess this would produce duplicated logs as well with your new validation right? Just something to keep in mind (you can also create a ticket / additional PR for adjusting Magento again, if that's necessary 🙈 )
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yep, basically all
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fyi: created a new ticket for checking the compatibility shopware/shopware#12442 |
||
| ); | ||
|
|
||
| return new ConvertStruct(null, $data); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fyi: this is needed as long as we haven't released the new
SwagMigrationAssistantversionThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
YAML should allow comments, so I would suggest adding something like
# Todo: change back to trunk after assistant epic gets merged https://github.com/shopware/shopware/issues/10417There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be switch again before merging this, so I thought a thread is more visible
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That also works, just thought this PR is targeting the feature branch in magento and later if the merge that feature branch into trunk again we would need to revert this change 🤷♂️ .
But either way, we just have to keep track of this somehow and a comment would at least be obvious during code review 😅