diff --git a/src/Profile/Shopware/Converter/CategoryConverter.php b/src/Profile/Shopware/Converter/CategoryConverter.php index 6ce10089c..b1797092b 100644 --- a/src/Profile/Shopware/Converter/CategoryConverter.php +++ b/src/Profile/Shopware/Converter/CategoryConverter.php @@ -85,8 +85,11 @@ public function convert( $this->connectionName = $connection->getName(); if (!isset($data['_locale'])) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(CategoryDefinition::ENTITY_NAME) + ->withFieldSourcePath('_locale') + ->withSourceData($data) ->build(EmptyNecessaryFieldRunLog::class) ); diff --git a/src/Profile/Shopware/Converter/CrossSellingConverter.php b/src/Profile/Shopware/Converter/CrossSellingConverter.php index a66276898..715254e91 100644 --- a/src/Profile/Shopware/Converter/CrossSellingConverter.php +++ b/src/Profile/Shopware/Converter/CrossSellingConverter.php @@ -7,6 +7,7 @@ namespace SwagMigrationAssistant\Profile\Shopware\Converter; +use Shopware\Core\Content\Product\Aggregate\ProductCrossSelling\ProductCrossSellingDefinition; use Shopware\Core\Framework\Context; use Shopware\Core\Framework\Log\Package; use SwagMigrationAssistant\Migration\Converter\ConvertStruct; @@ -59,8 +60,13 @@ public function convert(array $data, Context $context, MigrationContextInterface $sourceProductMapping = $this->getProductMapping($data['articleID']); if ($sourceProductMapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(ProductCrossSellingDefinition::ENTITY_NAME) + ->withFieldName('id') + ->withFieldSourcePath('articleID') + ->withSourceData($data) + ->withConvertedData($converted) ->build(AssociationRequiredMissingLog::class) ); @@ -70,8 +76,13 @@ public function convert(array $data, Context $context, MigrationContextInterface $relatedProductMapping = $this->getProductMapping($data['relatedarticle']); if ($relatedProductMapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(ProductCrossSellingDefinition::ENTITY_NAME) + ->withFieldName('id') + ->withFieldSourcePath('relatedarticle') + ->withSourceData($data) + ->withConvertedData($converted) ->build(AssociationRequiredMissingLog::class) ); diff --git a/src/Profile/Shopware/Converter/CustomerConverter.php b/src/Profile/Shopware/Converter/CustomerConverter.php index 4663eac34..88c4bbf91 100644 --- a/src/Profile/Shopware/Converter/CustomerConverter.php +++ b/src/Profile/Shopware/Converter/CustomerConverter.php @@ -7,6 +7,8 @@ namespace SwagMigrationAssistant\Profile\Shopware\Converter; +use Shopware\Core\Checkout\Customer\Aggregate\CustomerAddress\CustomerAddressDefinition; +use Shopware\Core\Checkout\Customer\CustomerDefinition; use Shopware\Core\Defaults; use Shopware\Core\Framework\Context; use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; @@ -107,8 +109,12 @@ public function convert( $fields = $this->checkForEmptyRequiredDataFields($data, $this->requiredDataFieldKeys); if (!empty($fields)) { - $this->loggingService->addLogEntry( // TODO: add optional fields - SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + $this->loggingService->addLogForEach( + $fields, + fn (string $key) => SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(CustomerDefinition::ENTITY_NAME) + ->withFieldSourcePath($key) + ->withSourceData($data) ->build(EmptyNecessaryFieldRunLog::class) ); @@ -116,8 +122,12 @@ public function convert( } if (!$this->checkEmailValidity($data['email'])) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(CustomerDefinition::ENTITY_NAME) + ->withFieldName('email') + ->withFieldSourcePath('email') + ->withSourceData($data) ->build(InvalidEmailAddressLog::class) ); @@ -227,8 +237,13 @@ public function convert( ); if ($mapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(CustomerDefinition::ENTITY_NAME) + ->withFieldName('defaultPaymentMethodId') + ->withFieldSourcePath('default_payment_method') + ->withSourceData($data) + ->withConvertedData($converted) ->build(EmptyNecessaryFieldRunLog::class) ); @@ -284,11 +299,30 @@ public function convert( $returnData = null; } - if (!isset($converted['defaultBillingAddressId'], $converted['defaultShippingAddressId'])) { + if (!isset($converted['defaultBillingAddressId'])) { $this->mappingService->deleteMapping($converted['id'], $this->connectionId, $this->context); - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(CustomerDefinition::ENTITY_NAME) + ->withFieldName('defaultBillingAddressId') + ->withFieldSourcePath('default_billing_address_id') + ->withSourceData($data) + ->build(EmptyNecessaryFieldRunLog::class) + ); + + return new ConvertStruct(null, $oldData); + } + + if (!isset($converted['defaultShippingAddressId'])) { + $this->mappingService->deleteMapping($converted['id'], $this->connectionId, $this->context); + + $this->loggingService->addLogEntry( + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(CustomerDefinition::ENTITY_NAME) + ->withFieldName('defaultShippingAddressId') + ->withFieldSourcePath('default_shipping_address_id') + ->withSourceData($data) ->build(EmptyNecessaryFieldRunLog::class) ); @@ -332,8 +366,12 @@ protected function getDefaultPaymentMethod(array $originalData): ?string ); if ($paymentMethodMapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(CustomerDefinition::ENTITY_NAME) + ->withFieldName('defaultPaymentMethodId') + ->withFieldSourcePath('default_payment_method') + ->withSourceData($originalData) ->build(UnknownEntityLog::class) ); @@ -357,8 +395,12 @@ protected function applyAddresses(array &$originalData, array &$converted, strin $fields = $this->checkForEmptyRequiredDataFields($address, $this->requiredAddressDataFieldKeys); if (!empty($fields)) { - $this->loggingService->addLogEntry( // TODO: add optional fields - SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + $this->loggingService->addLogForEach( + $fields, + fn (string $key) => SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(CustomerAddressDefinition::ENTITY_NAME) + ->withFieldSourcePath($key) + ->withSourceData($address) ->build(EmptyNecessaryFieldRunLog::class) ); @@ -539,8 +581,12 @@ protected function getCountryState(array $oldAddressData, string $newCountryId): $state = ['countryId' => $newCountryId]; if (!isset($oldAddressData['state_id'], $oldAddressData['country']['countryiso'], $oldAddressData['state']['shortcode'])) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(CustomerAddressDefinition::ENTITY_NAME) + ->withFieldName('stateId') + ->withFieldSourcePath('state_id') + ->withSourceData($oldAddressData) ->build(UnknownEntityLog::class) ); @@ -572,8 +618,12 @@ protected function getCountryState(array $oldAddressData, string $newCountryId): $oldAddressData['state']['position'], $oldAddressData['state']['active'] )) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(CustomerAddressDefinition::ENTITY_NAME) + ->withFieldName('stateId') + ->withFieldSourcePath('state.name') + ->withSourceData($oldAddressData['state']) ->build(UnknownEntityLog::class) ); @@ -643,8 +693,16 @@ protected function checkUnsetDefaultShippingAndDefaultBillingAddress(array &$ori $converted['defaultShippingAddressId'] = $addresses[0]['id']; unset($originalData['default_billing_address_id'], $originalData['default_shipping_address_id']); - $this->loggingService->addLogEntry( // TODO: add optional fields - SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + $this->loggingService->addLogForEach( + [ + 'defaultBillingAddressId' => 'default_billing_address_id', + 'defaultShippingAddressId' => 'default_shipping_address_id', + ], + fn (string $key, string $value) => SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(CustomerAddressDefinition::ENTITY_NAME) + ->withFieldName($key) + ->withFieldSourcePath($value) + ->withSourceData($originalData) ->build(FieldReassignedRunLog::class) ); } @@ -660,8 +718,12 @@ protected function checkUnsetDefaultShippingAddress(array &$originalData, array $converted['defaultShippingAddressId'] = $converted['defaultBillingAddressId']; unset($originalData['default_shipping_address_id']); - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(CustomerAddressDefinition::ENTITY_NAME) + ->withFieldName('defaultShippingAddressId') + ->withFieldSourcePath('default_shipping_address_id') + ->withSourceData($originalData) ->build(FieldReassignedRunLog::class) ); } @@ -677,8 +739,12 @@ protected function checkUnsetDefaultBillingAddress(array &$originalData, array & $converted['defaultBillingAddressId'] = $converted['defaultShippingAddressId']; unset($originalData['default_billing_address_id']); - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(CustomerAddressDefinition::ENTITY_NAME) + ->withFieldName('defaultBillingAddressId') + ->withFieldSourcePath('default_billing_address_id') + ->withSourceData($originalData) ->build(FieldReassignedRunLog::class) ); } @@ -694,8 +760,12 @@ protected function getSalutation(string $salutation): ?string ); if ($mapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(CustomerDefinition::ENTITY_NAME) + ->withFieldName('salutationId') + ->withFieldSourcePath('salutation') + ->withSourceData(['salutation' => $salutation]) ->build(UnknownEntityLog::class) ); diff --git a/src/Profile/Shopware/Converter/LanguageConverter.php b/src/Profile/Shopware/Converter/LanguageConverter.php index 04822064e..954c1b6b7 100644 --- a/src/Profile/Shopware/Converter/LanguageConverter.php +++ b/src/Profile/Shopware/Converter/LanguageConverter.php @@ -9,6 +9,7 @@ use Shopware\Core\Framework\Context; use Shopware\Core\Framework\Log\Package; +use Shopware\Core\System\Language\LanguageDefinition; use SwagMigrationAssistant\Migration\Converter\ConvertStruct; use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; @@ -50,8 +51,11 @@ public function convert(array $data, Context $context, MigrationContextInterface $languageUuid = $this->languageLookup->get($data['locale'], $context); if ($languageUuid !== null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(LanguageDefinition::ENTITY_NAME) + ->withFieldSourcePath('locale') + ->withSourceData($data) ->build(EntityAlreadyExistsRunLog::class) ); diff --git a/src/Profile/Shopware/Converter/MainVariantRelationConverter.php b/src/Profile/Shopware/Converter/MainVariantRelationConverter.php index f76cd714a..c8ad2b43a 100644 --- a/src/Profile/Shopware/Converter/MainVariantRelationConverter.php +++ b/src/Profile/Shopware/Converter/MainVariantRelationConverter.php @@ -109,12 +109,11 @@ public function convert(array $data, Context $context, MigrationContextInterface */ private function addAssociationRequiredLog(MigrationContextInterface $migrationContext, string $field, string $entity, array $data): void { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) ->withEntityName($entity) - ->withFieldName($field) ->withFieldSourcePath($field) - ->withSourceData([$data]) + ->withSourceData($data) ->build(AssociationRequiredMissingLog::class) ); } diff --git a/src/Profile/Shopware/Converter/NewsletterRecipientConverter.php b/src/Profile/Shopware/Converter/NewsletterRecipientConverter.php index aa6641c3d..2c9ba19ac 100644 --- a/src/Profile/Shopware/Converter/NewsletterRecipientConverter.php +++ b/src/Profile/Shopware/Converter/NewsletterRecipientConverter.php @@ -161,8 +161,11 @@ protected function getSalutation(string $salutation, MigrationContextInterface $ ); if ($salutationMapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(NewsletterRecipientDefinition::ENTITY_NAME) + ->withFieldName('salutationId') + ->withSourceData(['salutation' => $salutation]) ->build(UnknownEntityLog::class) ); @@ -188,8 +191,12 @@ protected function getSalesChannel(array $data): ?string } if (!isset($salesChannelMapping)) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(NewsletterRecipientDefinition::ENTITY_NAME) + ->withFieldName('salesChannelId') + ->withFieldSourcePath('shopId') + ->withSourceData($data) ->build(EmptyNecessaryFieldRunLog::class) ); @@ -210,8 +217,11 @@ protected function getStatus(MigrationContextInterface $migrationContext): ?stri ); if ($status === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(NewsletterRecipientDefinition::ENTITY_NAME) + ->withFieldName('status') + ->withSourceData(['status' => NewsletterRecipientStatusReader::SOURCE_ID]) ->build(EmptyNecessaryFieldRunLog::class) ); } diff --git a/src/Profile/Shopware/Converter/NumberRangeConverter.php b/src/Profile/Shopware/Converter/NumberRangeConverter.php index 48e3e4119..93fc5e4a4 100644 --- a/src/Profile/Shopware/Converter/NumberRangeConverter.php +++ b/src/Profile/Shopware/Converter/NumberRangeConverter.php @@ -14,6 +14,7 @@ use Shopware\Core\Framework\Log\Package; use Shopware\Core\Framework\Uuid\Uuid; use Shopware\Core\System\NumberRange\NumberRangeCollection; +use Shopware\Core\System\NumberRange\NumberRangeDefinition; use Shopware\Core\System\NumberRange\NumberRangeEntity; use SwagMigrationAssistant\Migration\Converter\ConvertStruct; use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; @@ -72,8 +73,12 @@ public function convert(array $data, Context $context, MigrationContextInterface $this->connectionId = $connection->getId(); if (!\array_key_exists($data['name'], self::TYPE_MAPPING)) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(NumberRangeDefinition::ENTITY_NAME) + ->withFieldName('typeId') + ->withFieldSourcePath('name') + ->withSourceData($data) ->build(UnsupportedNumberRangeTypeLog::class) ); @@ -85,8 +90,12 @@ public function convert(array $data, Context $context, MigrationContextInterface $converted['typeId'] = $this->getProductNumberRangeTypeUuid($data['name']); if (empty($converted['typeId'])) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(NumberRangeDefinition::ENTITY_NAME) + ->withFieldName('typeId') + ->withFieldSourcePath('name') + ->withSourceData($data) ->build(EmptyNecessaryFieldRunLog::class) ); diff --git a/src/Profile/Shopware/Converter/OrderConverter.php b/src/Profile/Shopware/Converter/OrderConverter.php index 3a852bcad..9f961cd25 100644 --- a/src/Profile/Shopware/Converter/OrderConverter.php +++ b/src/Profile/Shopware/Converter/OrderConverter.php @@ -17,6 +17,11 @@ use Shopware\Core\Checkout\Cart\Tax\Struct\TaxRule; use Shopware\Core\Checkout\Cart\Tax\Struct\TaxRuleCollection; use Shopware\Core\Checkout\Cart\Tax\TaxCalculator; +use Shopware\Core\Checkout\Order\Aggregate\OrderAddress\OrderAddressDefinition; +use Shopware\Core\Checkout\Order\Aggregate\OrderDelivery\OrderDeliveryDefinition; +use Shopware\Core\Checkout\Order\Aggregate\OrderLineItem\OrderLineItemDefinition; +use Shopware\Core\Checkout\Order\Aggregate\OrderTransaction\OrderTransactionDefinition; +use Shopware\Core\Checkout\Order\OrderDefinition; use Shopware\Core\Defaults; use Shopware\Core\Framework\Context; use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; @@ -132,8 +137,12 @@ public function convert( } if (!empty($fields)) { - $this->loggingService->addLogEntry( // TODO: add optional fields - SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + $this->loggingService->addLogForEach( + $fields, + fn (string $key) => SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(OrderDefinition::ENTITY_NAME) + ->withFieldSourcePath($key) + ->withSourceData($data) ->build(EmptyNecessaryFieldRunLog::class) ); @@ -211,8 +220,13 @@ public function convert( $currencyUuid = $this->currencyLookup->get($data['currency'], $context); } if ($currencyUuid === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(OrderDefinition::ENTITY_NAME) + ->withFieldName('currencyId') + ->withFieldSourcePath('currency') + ->withSourceData($data) + ->withConvertedData($converted) ->build(EmptyNecessaryFieldRunLog::class) ); @@ -238,8 +252,13 @@ public function convert( ); if ($stateMapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(OrderDefinition::ENTITY_NAME) + ->withFieldName('stateId') + ->withFieldSourcePath('status') + ->withSourceData($data) + ->withConvertedData($converted) ->build(UnknownEntityLog::class) ); @@ -313,8 +332,13 @@ public function convert( $billingAddress = $this->getAddress($data['billingaddress']); if (empty($billingAddress)) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(OrderDefinition::ENTITY_NAME) + ->withFieldName('billingAddressId') + ->withFieldSourcePath('billingaddress') + ->withSourceData($data) + ->withConvertedData($converted) ->build(EmptyNecessaryFieldRunLog::class) ); @@ -417,8 +441,13 @@ protected function applyTransactions(array $data, array &$converted): void ); if ($mapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(OrderTransactionDefinition::ENTITY_NAME) + ->withFieldName('stateId') + ->withFieldSourcePath('cleared') + ->withSourceData($data) + ->withConvertedData($converted) ->build(UnknownEntityLog::class) ); @@ -472,8 +501,12 @@ protected function getPaymentMethod(array $originalData): ?string ); if ($paymentMethodMapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(OrderTransactionDefinition::ENTITY_NAME) + ->withFieldName('paymentMethodId') + ->withFieldSourcePath('payment.id') + ->withSourceData($originalData) ->build(UnknownEntityLog::class) ); @@ -495,8 +528,12 @@ protected function getAddress(array $originalData, string $type = self::BILLING_ $fields = $this->checkForEmptyRequiredDataFields($originalData, $this->requiredAddressDataFieldKeys); if (!empty($fields)) { - $this->loggingService->addLogEntry( // TODO: add optional fields - SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + $this->loggingService->addLogForEach( + $fields, + fn (string $key) => SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(OrderDefinition::ENTITY_NAME) + ->withFieldSourcePath($key) + ->withSourceData($originalData) ->build(EmptyNecessaryFieldRunLog::class) ); @@ -638,8 +675,12 @@ protected function getCountryState(array $oldAddressData, string $newCountryId): $state = ['countryId' => $newCountryId]; if (!isset($oldAddressData['stateID'], $oldAddressData['country']['countryiso'], $oldAddressData['state']['shortcode'])) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(OrderAddressDefinition::ENTITY_NAME) + ->withFieldName('countryStateId') + ->withFieldSourcePath('stateID') + ->withSourceData($oldAddressData) ->build(UnknownEntityLog::class) ); @@ -671,8 +712,12 @@ protected function getCountryState(array $oldAddressData, string $newCountryId): $oldAddressData['state']['position'], $oldAddressData['state']['active'] )) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(OrderAddressDefinition::ENTITY_NAME) + ->withFieldName('countryStateId') + ->withFieldSourcePath('name') + ->withSourceData($oldAddressData['state']) ->build(UnknownEntityLog::class) ); @@ -747,8 +792,13 @@ protected function getDeliveries(array $data, array $converted, CalculatedPrice ); if ($deliveryStateMapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(OrderDeliveryDefinition::ENTITY_NAME) + ->withFieldName('stateId') + ->withFieldSourcePath('status') + ->withSourceData($data) + ->withConvertedData($converted) ->build(UnknownEntityLog::class) ); @@ -827,8 +877,12 @@ protected function getShippingMethod(string $shippingMethodId): ?string ); if ($shippingMethodMapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(OrderDeliveryDefinition::ENTITY_NAME) + ->withFieldName('shippingMethodId') + ->withFieldSourcePath('dispatchID') + ->withSourceData(['dispatchID' => $shippingMethodId]) ->build(UnknownEntityLog::class) ); @@ -991,8 +1045,12 @@ protected function getSalutation(string $salutation): ?string ); if ($salutationMapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(OrderAddressDefinition::ENTITY_NAME) + ->withFieldName('salutationId') + ->withFieldSourcePath('salutation') + ->withSourceData(['salutation' => $salutation]) ->build(UnknownEntityLog::class) ); @@ -1019,8 +1077,12 @@ private function getOrderLineItemDownload(array $originalEsdItem): ?array ); if (!\is_array($mediaMapping)) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(OrderLineItemDefinition::ENTITY_NAME) + ->withFieldName('coverId') + ->withFieldSourcePath('esd.esdID') + ->withSourceData($originalEsdItem) ->build(UnknownEntityLog::class) ); diff --git a/src/Profile/Shopware/Converter/OrderDocumentConverter.php b/src/Profile/Shopware/Converter/OrderDocumentConverter.php index 7f1cdc686..810957ce5 100644 --- a/src/Profile/Shopware/Converter/OrderDocumentConverter.php +++ b/src/Profile/Shopware/Converter/OrderDocumentConverter.php @@ -80,8 +80,12 @@ public function convert(array $data, Context $context, MigrationContextInterface $converted = []; if (empty($data['hash'])) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(DocumentDefinition::ENTITY_NAME) + ->withFieldSourcePath('hash') + ->withSourceData($data) + ->withConvertedData($converted) ->build(EmptyNecessaryFieldRunLog::class) ); @@ -89,8 +93,13 @@ public function convert(array $data, Context $context, MigrationContextInterface } if (!isset($data['documenttype'])) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(DocumentDefinition::ENTITY_NAME) + ->withFieldName('documentType') + ->withFieldSourcePath('documenttype') + ->withSourceData($data) + ->withConvertedData($converted) ->build(EmptyNecessaryFieldRunLog::class) ); @@ -105,8 +114,13 @@ public function convert(array $data, Context $context, MigrationContextInterface ); if ($orderMapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(DocumentDefinition::ENTITY_NAME) + ->withFieldName('orderId') + ->withFieldSourcePath('orderID') + ->withSourceData($data) + ->withConvertedData($converted) ->build(AssociationRequiredMissingLog::class) ); @@ -187,8 +201,13 @@ protected function getDocumentType(array $data): array return $documentType; } - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(DocumentDefinition::ENTITY_NAME) + ->withFieldName('documentType') + ->withFieldSourcePath('key') + ->withSourceData($data) + ->withConvertedData($documentType) ->build(DocumentTypeNotSupportedLog::class) ); diff --git a/src/Profile/Shopware/Converter/ProductConverter.php b/src/Profile/Shopware/Converter/ProductConverter.php index f361f85e2..208af37d5 100644 --- a/src/Profile/Shopware/Converter/ProductConverter.php +++ b/src/Profile/Shopware/Converter/ProductConverter.php @@ -7,8 +7,12 @@ namespace SwagMigrationAssistant\Profile\Shopware\Converter; +use Shopware\Core\Content\Media\MediaDefinition; use Shopware\Core\Content\Product\Aggregate\ProductDownload\ProductDownloadDefinition; +use Shopware\Core\Content\Product\Aggregate\ProductMedia\ProductMediaDefinition; +use Shopware\Core\Content\Product\Aggregate\ProductPrice\ProductPriceDefinition; use Shopware\Core\Content\Product\Aggregate\ProductVisibility\ProductVisibilityDefinition; +use Shopware\Core\Content\Product\ProductDefinition; use Shopware\Core\Defaults; use Shopware\Core\Framework\Context; use Shopware\Core\Framework\Log\Package; @@ -143,8 +147,12 @@ public function convert( $fields = $this->checkForEmptyRequiredDataFields($data, $this->requiredDataFieldKeys); if (!empty($fields)) { - $this->loggingService->addLogEntry( // TODO: add optional fields - SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + $this->loggingService->addLogForEach( + $fields, + fn (string $key) => SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(ProductDefinition::ENTITY_NAME) + ->withFieldSourcePath($key) + ->withSourceData($data) ->build(EmptyNecessaryFieldRunLog::class) ); @@ -382,8 +390,13 @@ private function getProductData(array &$data, array $converted): array $converted['price'] = $this->getPrice($data['prices'][0], $converted['tax']['taxRate']); if (empty($converted['price'])) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(ProductDefinition::ENTITY_NAME) + ->withFieldName('price') + ->withFieldSourcePath('prices') + ->withSourceData($data) + ->withConvertedData($converted) ->build(EmptyNecessaryFieldRunLog::class) ); } @@ -886,8 +899,13 @@ private function getEsdFiles(array $esdFiles, string $oldVariantId, array $conve $this->mappingIds[] = $mapping['id']; if (empty($esdFile['name'])) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(MediaDefinition::ENTITY_NAME) + ->withFieldName('name') + ->withFieldSourcePath('name') + ->withSourceData($esdFile) + ->withConvertedData($newMedia) ->build(CannotConvertChildEntityLog::class) ); @@ -896,9 +914,15 @@ private function getEsdFiles(array $esdFiles, string $oldVariantId, array $conve try { $path = \unserialize($esdFile['path'], ['allowed_classes' => false]); - } catch (\Throwable) { - $this->loggingService->addLogEntry( // TODO: add optional fields + } catch (\Throwable $e) { + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(MediaDefinition::ENTITY_NAME) + ->withFieldName('path') + ->withFieldSourcePath('path') + ->withSourceData($esdFile) + ->withExceptionMessage($e->getMessage()) + ->withExceptionTrace($e->getTrace()) ->build(CannotConvertChildEntityLog::class) ); @@ -928,8 +952,15 @@ private function getEsdFiles(array $esdFiles, string $oldVariantId, array $conve $albumId = $this->mediaFolderLookup->get(ProductDownloadDefinition::ENTITY_NAME, $this->context); if ($albumId === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(MediaDefinition::ENTITY_NAME) + ->withFieldName('mediaFolderId') + ->withSourceData([ + 'file_name' => $fileName, + 'source_data' => $sourceData, + 'media_folder' => ProductDownloadDefinition::ENTITY_NAME, + ]) ->build(CannotConvertChildEntityLog::class) ); @@ -960,8 +991,12 @@ private function getMedia(array $media, string $oldVariantId, array $converted): $mediaObjects = []; foreach ($media as $mediaData) { if (!isset($mediaData['media']['id'])) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(ProductMediaDefinition::ENTITY_NAME) + ->withFieldName('mediaId') + ->withFieldSourcePath('media.id') + ->withSourceData($mediaData) ->build(CannotConvertChildEntityLog::class) ); @@ -1348,8 +1383,13 @@ private function getPrices(array $priceData, array $converted): array $priceArray = $this->getPrice($price, $converted['tax']['taxRate']); if (empty($priceArray)) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(ProductPriceDefinition::ENTITY_NAME) + ->withFieldName('price') + ->withFieldSourcePath('price') + ->withSourceData($price) + ->withConvertedData($converted) ->build(EmptyNecessaryFieldRunLog::class) ); diff --git a/src/Profile/Shopware/Converter/ProductReviewConverter.php b/src/Profile/Shopware/Converter/ProductReviewConverter.php index 34f3afa33..3941b71ba 100644 --- a/src/Profile/Shopware/Converter/ProductReviewConverter.php +++ b/src/Profile/Shopware/Converter/ProductReviewConverter.php @@ -7,6 +7,7 @@ namespace SwagMigrationAssistant\Profile\Shopware\Converter; +use Shopware\Core\Content\Product\Aggregate\ProductReview\ProductReviewDefinition; use Shopware\Core\Framework\Context; use Shopware\Core\Framework\Log\Package; use SwagMigrationAssistant\Migration\Converter\ConvertStruct; @@ -46,8 +47,12 @@ public function convert(array $data, Context $context, MigrationContextInterface $connectionId = $connection->getId(); if (!empty($fields)) { - $this->loggingService->addLogEntry( // TODO: add optional fields - SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + $this->loggingService->addLogForEach( + $fields, + fn (string $key) => SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(ProductReviewDefinition::ENTITY_NAME) + ->withFieldSourcePath($key) + ->withSourceData($data) ->build(EmptyNecessaryFieldRunLog::class) ); @@ -85,8 +90,13 @@ public function convert(array $data, Context $context, MigrationContextInterface ); if ($mapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(ProductReviewDefinition::ENTITY_NAME) + ->withFieldName('productId') + ->withFieldSourcePath('articleID') + ->withSourceData($data) + ->withConvertedData($converted) ->build(AssociationRequiredMissingLog::class) ); @@ -122,8 +132,13 @@ public function convert(array $data, Context $context, MigrationContextInterface ); if ($mapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(ProductReviewDefinition::ENTITY_NAME) + ->withFieldName('salesChannelId') + ->withFieldSourcePath('shop_id') + ->withSourceData($data) + ->withConvertedData($converted) ->build(AssociationRequiredMissingLog::class) ); @@ -135,8 +150,13 @@ public function convert(array $data, Context $context, MigrationContextInterface $converted['languageId'] = $this->languageLookup->get($mainLocale, $context); if ($converted['languageId'] === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(ProductReviewDefinition::ENTITY_NAME) + ->withFieldName('languageId') + ->withFieldSourcePath('_locale') + ->withSourceData($data) + ->withConvertedData($converted) ->build(AssociationRequiredMissingLog::class) ); diff --git a/src/Profile/Shopware/Converter/PromotionConverter.php b/src/Profile/Shopware/Converter/PromotionConverter.php index 6e68c4b33..5681ec178 100644 --- a/src/Profile/Shopware/Converter/PromotionConverter.php +++ b/src/Profile/Shopware/Converter/PromotionConverter.php @@ -7,7 +7,10 @@ namespace SwagMigrationAssistant\Profile\Shopware\Converter; +use Shopware\Core\Checkout\Promotion\Aggregate\PromotionCartRule\PromotionCartRuleDefinition; use Shopware\Core\Checkout\Promotion\Aggregate\PromotionDiscount\PromotionDiscountEntity; +use Shopware\Core\Checkout\Promotion\Aggregate\PromotionPersonaRule\PromotionPersonaRuleDefinition; +use Shopware\Core\Checkout\Promotion\PromotionDefinition; use Shopware\Core\Framework\Context; use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria; @@ -364,8 +367,12 @@ private function setProductNumbers(array &$data, MigrationContextInterface $migr ); if ($productMapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(PromotionDefinition::ENTITY_NAME) + ->withFieldName('productId') + ->withFieldSourcePath('restrictarticles') + ->withSourceData($data) ->build(AssociationRequiredMissingLog::class) ); @@ -495,8 +502,12 @@ private function setCartRule(array &$data, array &$converted, MigrationContextIn unset($data['bindtosupplier']); $oneRuleAdded = true; } else { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(PromotionCartRuleDefinition::ENTITY_NAME) + ->withFieldName('rule.value.manufacturerId') + ->withFieldSourcePath('bindtosupplier') + ->withSourceData($data) ->build(AssociationRequiredMissingLog::class) ); } @@ -546,8 +557,13 @@ private function setSalesChannel(array &$data, array &$converted, MigrationConte ); if ($salesChannelMapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(PromotionDefinition::ENTITY_NAME) + ->withFieldName('salesChannelId') + ->withFieldSourcePath('subshopID') + ->withSourceData($data) + ->withConvertedData($converted) ->build(AssociationRequiredMissingLog::class) ); @@ -614,8 +630,13 @@ private function setCustomerRule(array &$data, array &$converted, MigrationConte ); if ($customerGroupMapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(PromotionPersonaRuleDefinition::ENTITY_NAME) + ->withFieldName('rule.value.customerGroupId') + ->withFieldSourcePath('customergroup') + ->withSourceData($data) + ->withConvertedData($converted) ->build(AssociationRequiredMissingLog::class) ); diff --git a/src/Profile/Shopware/Converter/PropertyGroupOptionConverter.php b/src/Profile/Shopware/Converter/PropertyGroupOptionConverter.php index f1f121031..5537e503e 100644 --- a/src/Profile/Shopware/Converter/PropertyGroupOptionConverter.php +++ b/src/Profile/Shopware/Converter/PropertyGroupOptionConverter.php @@ -7,6 +7,7 @@ namespace SwagMigrationAssistant\Profile\Shopware\Converter; +use Shopware\Core\Content\Property\PropertyGroupDefinition; use Shopware\Core\Framework\Context; use Shopware\Core\Framework\Log\Package; use SwagMigrationAssistant\Migration\Converter\ConvertStruct; @@ -76,8 +77,12 @@ public function convert(array $data, Context $context, MigrationContextInterface $this->connectionId = $connection->getId(); if (!isset($data['group']['name'])) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(PropertyGroupDefinition::ENTITY_NAME) + ->withFieldName('id') + ->withFieldSourcePath('group.name') + ->withSourceData($data) ->build(EmptyNecessaryFieldRunLog::class) ); @@ -128,8 +133,12 @@ public function convert(array $data, Context $context, MigrationContextInterface protected function setMedia(array &$converted, array $data): void { if (!isset($data['media']['id'])) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(PropertyGroupDefinition::ENTITY_NAME) + ->withFieldName('media.id') + ->withFieldSourcePath('media.id') + ->withSourceData($data) ->build(CannotConvertChildEntityLog::class) ); diff --git a/src/Profile/Shopware/Converter/SalesChannelConverter.php b/src/Profile/Shopware/Converter/SalesChannelConverter.php index 1e911f66e..634269d8f 100644 --- a/src/Profile/Shopware/Converter/SalesChannelConverter.php +++ b/src/Profile/Shopware/Converter/SalesChannelConverter.php @@ -20,6 +20,7 @@ use Shopware\Core\Framework\Log\Package; use Shopware\Core\System\Country\CountryCollection; use Shopware\Core\System\SalesChannel\SalesChannelCollection; +use Shopware\Core\System\SalesChannel\SalesChannelDefinition; use SwagMigrationAssistant\Migration\Converter\ConvertStruct; use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; use SwagMigrationAssistant\Migration\Logging\Log\AssociationRequiredMissingLog; @@ -96,8 +97,12 @@ public function convert(array $data, Context $context, MigrationContextInterface ); if ($customerGroupMapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(SalesChannelDefinition::ENTITY_NAME) + ->withFieldName('customerGroupId') + ->withFieldSourcePath('customer_group_id') + ->withSourceData($data) ->build(AssociationRequiredMissingLog::class) ); @@ -109,8 +114,12 @@ public function convert(array $data, Context $context, MigrationContextInterface $languageUuid = $this->languageLookup->get($data['locale'], $context); if ($languageUuid === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(SalesChannelDefinition::ENTITY_NAME) + ->withFieldName('languageId') + ->withFieldSourcePath('locale') + ->withSourceData($data) ->build(AssociationRequiredMissingLog::class) ); @@ -129,8 +138,12 @@ public function convert(array $data, Context $context, MigrationContextInterface $currencyUuid = $this->currencyLookup->get($data['currency'], $context); if ($currencyUuid === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(SalesChannelDefinition::ENTITY_NAME) + ->withFieldName('currencyId') + ->withFieldSourcePath('currency') + ->withSourceData($data) ->build(AssociationRequiredMissingLog::class) ); @@ -152,8 +165,12 @@ public function convert(array $data, Context $context, MigrationContextInterface ); if ($categoryMapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(SalesChannelDefinition::ENTITY_NAME) + ->withFieldName('navigationCategoryId') + ->withFieldSourcePath('category_id') + ->withSourceData($data) ->build(AssociationRequiredMissingLog::class) ); @@ -372,8 +389,10 @@ protected function filterDisabledPackLanguages(array &$converted): void $converted['languageId'] = Defaults::LANGUAGE_SYSTEM; } - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(SalesChannelDefinition::ENTITY_NAME) + ->withFieldName('languageId') ->build(DeactivatedPackLanguageLog::class) ); } diff --git a/src/Profile/Shopware/Converter/SeoUrlConverter.php b/src/Profile/Shopware/Converter/SeoUrlConverter.php index 565a5c662..88c887ecf 100644 --- a/src/Profile/Shopware/Converter/SeoUrlConverter.php +++ b/src/Profile/Shopware/Converter/SeoUrlConverter.php @@ -7,6 +7,7 @@ namespace SwagMigrationAssistant\Profile\Shopware\Converter; +use Shopware\Core\Content\Seo\SeoUrl\SeoUrlDefinition; use Shopware\Core\Framework\Context; use Shopware\Core\Framework\Log\Package; use SwagMigrationAssistant\Migration\Converter\ConvertStruct; @@ -65,8 +66,13 @@ public function convert(array $data, Context $context, MigrationContextInterface ); if ($mapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(SeoUrlDefinition::ENTITY_NAME) + ->withFieldName('salesChannelId') + ->withFieldSourcePath('subshopID') + ->withSourceData($data) + ->withConvertedData($converted) ->build(AssociationRequiredMissingLog::class) ); @@ -78,8 +84,13 @@ public function convert(array $data, Context $context, MigrationContextInterface $converted['languageId'] = $this->languageLookup->get($data['_locale'], $context); if ($converted['languageId'] === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(SeoUrlDefinition::ENTITY_NAME) + ->withFieldName('languageId') + ->withFieldSourcePath('_locale') + ->withSourceData($data) + ->withConvertedData($converted) ->build(AssociationRequiredMissingLog::class) ); @@ -105,8 +116,12 @@ public function convert(array $data, Context $context, MigrationContextInterface ); if ($mapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(SeoUrlDefinition::ENTITY_NAME) + ->withFieldName('foreignKey') + ->withFieldSourcePath('type') + ->withSourceData($data) ->build(AssociationRequiredMissingLog::class) ); @@ -127,8 +142,12 @@ public function convert(array $data, Context $context, MigrationContextInterface ); if ($mapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(SeoUrlDefinition::ENTITY_NAME) + ->withFieldName('foreignKey') + ->withFieldSourcePath('type') + ->withSourceData($data) ->build(AssociationRequiredMissingLog::class) ); @@ -139,8 +158,12 @@ public function convert(array $data, Context $context, MigrationContextInterface $converted['pathInfo'] = '/navigation/' . $mapping['entityUuid']; $this->mappingIds[] = $mapping['id']; } else { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(SeoUrlDefinition::ENTITY_NAME) + ->withFieldName('foreignKey') + ->withFieldSourcePath('type') + ->withSourceData($data) ->build(UnsupportedSeoUrlTypeLog::class) ); diff --git a/src/Profile/Shopware/Converter/ShippingMethodConverter.php b/src/Profile/Shopware/Converter/ShippingMethodConverter.php index 0c71b8c60..3c0ed66d1 100644 --- a/src/Profile/Shopware/Converter/ShippingMethodConverter.php +++ b/src/Profile/Shopware/Converter/ShippingMethodConverter.php @@ -7,6 +7,8 @@ namespace SwagMigrationAssistant\Profile\Shopware\Converter; +use Shopware\Core\Checkout\Shipping\Aggregate\ShippingMethodPrice\ShippingMethodPriceDefinition; +use Shopware\Core\Checkout\Shipping\ShippingMethodDefinition; use Shopware\Core\Framework\Context; use Shopware\Core\Framework\Log\Package; use Shopware\Core\Framework\Rule\Container\AndRule; @@ -93,8 +95,12 @@ public function convert(array $data, Context $context, MigrationContextInterface $this->connectionId = $connection->getId(); if (empty($data['id'])) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(ShippingMethodDefinition::ENTITY_NAME) + ->withFieldName('id') + ->withFieldSourcePath('id') + ->withSourceData($data) ->build(EmptyNecessaryFieldRunLog::class) ); @@ -143,12 +149,14 @@ public function convert(array $data, Context $context, MigrationContextInterface $fields = $this->checkForEmptyRequiredConvertedFields($converted, $this->requiredDataFields); if (!empty($fields)) { - foreach ($fields as $field) { - $this->loggingService->addLogEntry( // TODO: add optional fields - SwagMigrationLogBuilder::fromMigrationContext($migrationContext) - ->build(EmptyNecessaryFieldRunLog::class) - ); - } + $this->loggingService->addLogForEach( + $fields, + fn (string $key) => SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withFieldName(ShippingMethodDefinition::ENTITY_NAME) + ->withFieldSourcePath($key) + ->withSourceData($data) + ->build(EmptyNecessaryFieldRunLog::class) + ); return new ConvertStruct(null, $data); } @@ -178,8 +186,13 @@ public function convert(array $data, Context $context, MigrationContextInterface if (!isset($data['calculation']) || !\array_key_exists($data['calculation'], self::CALCULATION_TYPE_MAPPING) ) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(ShippingMethodDefinition::ENTITY_NAME) + ->withFieldName('prices') + ->withFieldSourcePath('calculation') + ->withSourceData($data) + ->withConvertedData($converted) ->build(UnsupportedShippingCalculationTypeLog::class) ); } else { @@ -233,8 +246,12 @@ public function convert(array $data, Context $context, MigrationContextInterface $this->updateMainMapping($migrationContext, $context); if (!\is_array($this->mainMapping) || !\array_key_exists('id', $this->mainMapping)) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(ShippingMethodDefinition::ENTITY_NAME) + ->withFieldName('id') + ->withSourceData($data) + ->withConvertedData($converted) ->build(EmptyNecessaryFieldRunLog::class) ); @@ -634,8 +651,12 @@ protected function getShippingCosts(MigrationContextInterface $migrationContext, $convertedCosts = []; foreach ($shippingCosts as $key => $shippingCost) { if (empty($shippingCost['id'])) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(ShippingMethodPriceDefinition::ENTITY_NAME) + ->withFieldName('id') + ->withFieldSourcePath('id') + ->withSourceData($data) ->build(EmptyNecessaryFieldRunLog::class) ); @@ -667,8 +688,12 @@ protected function getShippingCosts(MigrationContextInterface $migrationContext, } if (!isset($currencyMapping)) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(ShippingMethodPriceDefinition::ENTITY_NAME) + ->withFieldName('currencyId') + ->withFieldSourcePath('currencyShortName') + ->withSourceData($data) ->build(EmptyNecessaryFieldRunLog::class) ); @@ -682,8 +707,12 @@ protected function getShippingCosts(MigrationContextInterface $migrationContext, } if (isset($shippingCost['factor']) && $shippingCost['factor'] > 0) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(ShippingMethodPriceDefinition::ENTITY_NAME) + ->withFieldSourcePath('factor') + ->withSourceData($shippingCost) + ->withConvertedData($cost) ->build(UnsupportedShippingPriceLog::class) ); diff --git a/src/Profile/Shopware/Converter/TranslationConverter.php b/src/Profile/Shopware/Converter/TranslationConverter.php index abe5d81e6..7a9da3d1c 100644 --- a/src/Profile/Shopware/Converter/TranslationConverter.php +++ b/src/Profile/Shopware/Converter/TranslationConverter.php @@ -7,14 +7,21 @@ namespace SwagMigrationAssistant\Profile\Shopware\Converter; +use Shopware\Core\Content\Category\Aggregate\CategoryTranslation\CategoryTranslationDefinition; use Shopware\Core\Content\Category\CategoryDefinition; +use Shopware\Core\Content\Media\Aggregate\MediaTranslation\MediaTranslationDefinition; use Shopware\Core\Content\Media\MediaDefinition; use Shopware\Core\Content\Product\Aggregate\ProductManufacturer\ProductManufacturerDefinition; +use Shopware\Core\Content\Product\Aggregate\ProductManufacturerTranslation\ProductManufacturerTranslationDefinition; +use Shopware\Core\Content\Product\Aggregate\ProductTranslation\ProductTranslationDefinition; use Shopware\Core\Content\Product\ProductDefinition; use Shopware\Core\Content\Property\Aggregate\PropertyGroupOption\PropertyGroupOptionDefinition; +use Shopware\Core\Content\Property\Aggregate\PropertyGroupOptionTranslation\PropertyGroupOptionTranslationDefinition; +use Shopware\Core\Content\Property\Aggregate\PropertyGroupTranslation\PropertyGroupTranslationDefinition; use Shopware\Core\Content\Property\PropertyGroupDefinition; use Shopware\Core\Framework\Context; use Shopware\Core\Framework\Log\Package; +use Shopware\Core\System\Unit\Aggregate\UnitTranslation\UnitTranslationDefinition; use Shopware\Core\System\Unit\UnitDefinition; use SwagMigrationAssistant\Migration\Connection\Helper\ConnectionNameSanitizer; use SwagMigrationAssistant\Migration\Converter\ConvertStruct; @@ -60,8 +67,12 @@ public function convert( $this->connectionId = $connection->getId(); if (!isset($data['locale'])) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName('unknown_translation') + ->withFieldName('languageId') + ->withFieldSourcePath('locale') + ->withSourceData($data) ->build(EmptyNecessaryFieldRunLog::class) ); @@ -92,8 +103,11 @@ public function convert( return $this->createProductMediaTranslation($data); } - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName('unknown_translation') + ->withFieldSourcePath('objecttype') + ->withSourceData($data) ->build(UnsupportedTranslationTypeLog::class) ); @@ -124,8 +138,12 @@ protected function createProductTranslation(array &$data): ConvertStruct } if ($mapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(ProductTranslationDefinition::ENTITY_NAME) + ->withFieldName('productId') + ->withFieldSourcePath('objectkey') + ->withSourceData($sourceData) ->build(AssociationRequiredMissingLog::class) ); @@ -231,8 +249,12 @@ protected function createProductVariantTranslation(array &$data): ConvertStruct unset($data['ordernumber']); if ($mapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(ProductTranslationDefinition::ENTITY_NAME) + ->withFieldName('productId') + ->withFieldSourcePath('ordernumber') + ->withSourceData($sourceData) ->build(AssociationRequiredMissingLog::class) ); @@ -303,8 +325,12 @@ protected function createManufacturerProductTranslation(array $data): ConvertStr ); if ($mapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(ProductManufacturerTranslationDefinition::ENTITY_NAME) + ->withFieldName('productManufacturerId') + ->withFieldSourcePath('objectkey') + ->withSourceData($sourceData) ->build(AssociationRequiredMissingLog::class) ); @@ -381,8 +407,12 @@ protected function createUnitTranslation(array $data): ConvertStruct ); if ($mapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(UnitTranslationDefinition::ENTITY_NAME) + ->withFieldName('unitId') + ->withFieldSourcePath('objectkey') + ->withSourceData($sourceData) ->build(AssociationRequiredMissingLog::class) ); @@ -464,8 +494,12 @@ protected function createCategoryTranslation(array $data): ConvertStruct ); if ($mapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(CategoryTranslationDefinition::ENTITY_NAME) + ->withFieldName('categoryId') + ->withFieldSourcePath('objectkey') + ->withSourceData($sourceData) ->build(AssociationRequiredMissingLog::class) ); @@ -557,8 +591,12 @@ protected function createConfiguratorOptionTranslation(array $data): ConvertStru ); if ($mapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(PropertyGroupOptionTranslationDefinition::ENTITY_NAME) + ->withFieldName('propertyGroupOptionId') + ->withFieldSourcePath('objectkey') + ->withSourceData($sourceData) ->build(AssociationRequiredMissingLog::class) ); @@ -632,8 +670,12 @@ protected function createConfiguratorOptionGroupTranslation(array $data): Conver ); if ($mapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(PropertyGroupTranslationDefinition::ENTITY_NAME) + ->withFieldName('propertyGroupId') + ->withFieldSourcePath('objectkey') + ->withSourceData($sourceData) ->build(AssociationRequiredMissingLog::class) ); @@ -710,8 +752,12 @@ protected function createPropertyValueTranslation(array $data): ConvertStruct ); if ($mapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(PropertyGroupOptionTranslationDefinition::ENTITY_NAME) + ->withFieldName('propertyGroupOptionId') + ->withFieldSourcePath('objectkey') + ->withSourceData($sourceData) ->build(AssociationRequiredMissingLog::class) ); @@ -783,8 +829,12 @@ protected function createPropertyOptionTranslation(array $data): ConvertStruct ); if ($mapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(PropertyGroupTranslationDefinition::ENTITY_NAME) + ->withFieldName('propertyGroupId') + ->withFieldSourcePath('objectkey') + ->withSourceData($sourceData) ->build(AssociationRequiredMissingLog::class) ); @@ -902,17 +952,23 @@ protected function addAttribute(string $entityName, string $key, string $value, protected function unserializeTranslation(array $data, string $entity): ?array { $objectDataSerialized = $data['objectdata']; + $exception = null; try { $objectData = \unserialize($objectDataSerialized, ['allowed_classes' => false]); - } catch (\Throwable) { + } catch (\Throwable $e) { $objectData = null; + $exception = $e; } if (!\is_array($objectData)) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) ->withEntityName($entity) + ->withFieldSourcePath('objectdata') + ->withSourceData($data) + ->withExceptionMessage($exception?->getMessage() ?? 'Unserialization failed') + ->withExceptionTrace($exception?->getTrace() ?? []) ->build(InvalidUnserializedDataLog::class) ); @@ -941,8 +997,12 @@ protected function createProductMediaTranslation(array $data): ConvertStruct ); if ($mapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(MediaTranslationDefinition::ENTITY_NAME) + ->withFieldName('mediaId') + ->withFieldSourcePath('mediaId') + ->withSourceData($sourceData) ->build(AssociationRequiredMissingLog::class) ); diff --git a/src/Profile/Shopware/Gateway/Api/Reader/TableCountReader.php b/src/Profile/Shopware/Gateway/Api/Reader/TableCountReader.php index 92807550d..169ccf6cd 100644 --- a/src/Profile/Shopware/Gateway/Api/Reader/TableCountReader.php +++ b/src/Profile/Shopware/Gateway/Api/Reader/TableCountReader.php @@ -69,7 +69,7 @@ private function prepareTotals(array $result): array private function logExceptions(array $exceptionArray, MigrationContextInterface $migrationContext, Context $context): void { foreach ($exceptionArray as $exception) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) ->withExceptionMessage($exception['message']) ->build(CannotReadEntityCountLog::class) diff --git a/src/Profile/Shopware/Media/LocalMediaProcessor.php b/src/Profile/Shopware/Media/LocalMediaProcessor.php index 85bae475a..abdb1025f 100644 --- a/src/Profile/Shopware/Media/LocalMediaProcessor.php +++ b/src/Profile/Shopware/Media/LocalMediaProcessor.php @@ -10,6 +10,7 @@ use Doctrine\DBAL\Connection; use Shopware\Core\Content\Media\File\FileSaver; use Shopware\Core\Content\Media\File\MediaFile; +use Shopware\Core\Content\Media\MediaDefinition; use Shopware\Core\Content\Media\MediaException; use Shopware\Core\Framework\Context; use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; @@ -129,8 +130,14 @@ private function copyMediaFiles( if ($resolver === null) { $mappedWorkload[$mediaId]->setState(MediaProcessWorkloadStruct::ERROR_STATE); - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(MediaDefinition::ENTITY_NAME) + ->withSourceData([ + 'media_id' => $mediaId, + 'source_path' => $sourcePath, + 'media' => $mediaFile, + ]) ->build(CannotGetFileRunLog::class) ); $processedMedia[] = $mediaId; @@ -146,8 +153,14 @@ private function copyMediaFiles( $failedMedia[] = $mediaId; $mappedWorkload[$mediaId]->setState(MediaProcessWorkloadStruct::ERROR_STATE); - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(MediaDefinition::ENTITY_NAME) + ->withSourceData([ + 'media_id' => $mediaId, + 'source_path' => $sourcePath, + 'media' => $mediaFile, + ]) ->build(TemporaryFileErrorLog::class) ); @@ -175,8 +188,14 @@ private function copyMediaFiles( $mappedWorkload[$mediaId]->setState(MediaProcessWorkloadStruct::ERROR_STATE); $failedMedia[] = $mediaId; - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(MediaDefinition::ENTITY_NAME) + ->withSourceData([ + 'media_id' => $mediaId, + 'source_path' => $sourcePath, + 'media' => $mediaFile, + ]) ->withExceptionMessage($e->getMessage()) ->withExceptionTrace($e->getTrace()) ->build(ExceptionRunLog::class) @@ -185,8 +204,14 @@ private function copyMediaFiles( \unlink($filePath); } else { $mappedWorkload[$mediaId]->setState(MediaProcessWorkloadStruct::ERROR_STATE); - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(MediaDefinition::ENTITY_NAME) + ->withSourceData([ + 'media_id' => $mediaId, + 'source_path' => $sourcePath, + 'media' => $mediaFile, + ]) ->build(CannotGetFileRunLog::class) ); $failedMedia[] = $mediaId; @@ -221,8 +246,14 @@ private function persistFileToMedia( $failedMedia[] = $mediaId; $mappedWorkload[$mediaId]->setState(MediaProcessWorkloadStruct::ERROR_STATE); - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(MediaDefinition::ENTITY_NAME) + ->withSourceData([ + 'media_id' => $mediaId, + 'file_path' => $filePath, + 'media' => $media, + ]) ->build(MimeTypeErrorLog::class) ); diff --git a/src/Profile/Shopware/Media/LocalOrderDocumentProcessor.php b/src/Profile/Shopware/Media/LocalOrderDocumentProcessor.php index e4d52ec39..1c32d479c 100644 --- a/src/Profile/Shopware/Media/LocalOrderDocumentProcessor.php +++ b/src/Profile/Shopware/Media/LocalOrderDocumentProcessor.php @@ -8,6 +8,7 @@ namespace SwagMigrationAssistant\Profile\Shopware\Media; use Doctrine\DBAL\Connection; +use Shopware\Core\Content\Media\MediaDefinition; use Shopware\Core\Content\Media\MediaException; use Shopware\Core\Content\Media\MediaService; use Shopware\Core\Framework\Context; @@ -96,10 +97,18 @@ private function copyMediaFiles( if (!\is_file($sourcePath)) { $mappedWorkload[$mediaId]->setState(MediaProcessWorkloadStruct::ERROR_STATE); - $this->loggingService->addLogEntry( // TODO: add optional fields + + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(MediaDefinition::ENTITY_NAME) + ->withSourceData([ + 'media_id' => $mediaId, + 'source_path' => $sourcePath, + 'media' => $mappedWorkload[$mediaId], + ]) ->build(CannotGetFileRunLog::class) ); + $processedMedia[] = $mediaId; $failedMedia[] = $mediaId; @@ -117,10 +126,15 @@ private function copyMediaFiles( $mappedWorkload[$mediaId]->setState(MediaProcessWorkloadStruct::ERROR_STATE); - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) ->withExceptionMessage($e->getMessage()) ->withExceptionTrace($e->getTrace()) + ->withSourceData([ + 'media_id' => $mediaId, + 'source_path' => $sourcePath, + 'media' => $mappedWorkload[$mediaId], + ]) ->build(ExceptionRunLog::class) ); } diff --git a/src/Profile/Shopware/Media/LocalProductDownloadProcessor.php b/src/Profile/Shopware/Media/LocalProductDownloadProcessor.php index 97f68097b..034b0b946 100644 --- a/src/Profile/Shopware/Media/LocalProductDownloadProcessor.php +++ b/src/Profile/Shopware/Media/LocalProductDownloadProcessor.php @@ -8,6 +8,7 @@ namespace SwagMigrationAssistant\Profile\Shopware\Media; use Doctrine\DBAL\Connection; +use Shopware\Core\Content\Media\MediaDefinition; use Shopware\Core\Content\Media\MediaException; use Shopware\Core\Content\Media\MediaService; use Shopware\Core\Framework\Context; @@ -101,8 +102,14 @@ private function copyMediaFiles( if (!\is_file($sourcePath)) { $mappedWorkload[$mediaId]->setState(MediaProcessWorkloadStruct::ERROR_STATE); - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(MediaDefinition::ENTITY_NAME) + ->withSourceData([ + 'media_id' => $mediaId, + 'source_path' => $sourcePath, + 'media' => $mappedWorkload[$mediaId], + ]) ->build(CannotGetFileRunLog::class) ); $processedMedia[] = $mediaId; @@ -122,8 +129,14 @@ private function copyMediaFiles( $mappedWorkload[$mediaId]->setState(MediaProcessWorkloadStruct::ERROR_STATE); - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(MediaDefinition::ENTITY_NAME) + ->withSourceData([ + 'media_id' => $mediaId, + 'source_path' => $sourcePath, + 'media' => $mappedWorkload[$mediaId], + ]) ->withExceptionMessage($e->getMessage()) ->withExceptionTrace($e->getTrace()) ->build(ExceptionRunLog::class) diff --git a/src/Profile/Shopware6/Converter/DocumentBaseConfigConverter.php b/src/Profile/Shopware6/Converter/DocumentBaseConfigConverter.php index 72fcb88d0..f2cb61489 100644 --- a/src/Profile/Shopware6/Converter/DocumentBaseConfigConverter.php +++ b/src/Profile/Shopware6/Converter/DocumentBaseConfigConverter.php @@ -7,6 +7,7 @@ namespace SwagMigrationAssistant\Profile\Shopware6\Converter; +use Shopware\Core\Checkout\Document\Aggregate\DocumentBaseConfig\DocumentBaseConfigDefinition; use Shopware\Core\Framework\Log\Package; use SwagMigrationAssistant\Migration\Converter\ConvertStruct; use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; @@ -58,8 +59,13 @@ protected function convertData(array $data): ConvertStruct $converted['documentTypeId'] = $this->documentTypeLookup->get($converted['documentType']['technicalName'], $this->context); if ($converted['documentTypeId'] === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(DocumentBaseConfigDefinition::ENTITY_NAME) + ->withFieldName('documentTypeId') + ->withFieldSourcePath('id') + ->withSourceData($data) + ->withConvertedData($converted) ->build(UnsupportedDocumentTypeLog::class) ); diff --git a/src/Profile/Shopware6/Converter/DocumentConverter.php b/src/Profile/Shopware6/Converter/DocumentConverter.php index 75ad9ca16..f74e5d845 100644 --- a/src/Profile/Shopware6/Converter/DocumentConverter.php +++ b/src/Profile/Shopware6/Converter/DocumentConverter.php @@ -7,6 +7,7 @@ namespace SwagMigrationAssistant\Profile\Shopware6\Converter; +use Shopware\Core\Checkout\Document\DocumentDefinition; use Shopware\Core\Framework\Log\Package; use SwagMigrationAssistant\Migration\Converter\ConvertStruct; use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; @@ -64,8 +65,13 @@ protected function convertData(array $data): ConvertStruct $converted['documentTypeId'] = $this->documentTypeLookup->get($converted['documentType']['technicalName'], $this->context); if ($converted['documentTypeId'] === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(DocumentDefinition::ENTITY_NAME) + ->withFieldName('documentTypeId') + ->withFieldSourcePath('id') + ->withSourceData($data) + ->withConvertedData($converted) ->build(UnsupportedDocumentTypeLog::class) ); diff --git a/src/Profile/Shopware6/Converter/MailTemplateConverter.php b/src/Profile/Shopware6/Converter/MailTemplateConverter.php index d079a2702..dd8c6b1b0 100644 --- a/src/Profile/Shopware6/Converter/MailTemplateConverter.php +++ b/src/Profile/Shopware6/Converter/MailTemplateConverter.php @@ -7,6 +7,7 @@ namespace SwagMigrationAssistant\Profile\Shopware6\Converter; +use Shopware\Core\Content\MailTemplate\MailTemplateDefinition; use Shopware\Core\Framework\Log\Package; use SwagMigrationAssistant\Migration\Converter\ConvertStruct; use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; @@ -65,8 +66,11 @@ protected function convertData(array $data): ConvertStruct } else { $typeUuid = $this->mailTemplateTypeLookup->get($converted['mailTemplateType']['technicalName'], $this->context); if ($typeUuid === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(MailTemplateDefinition::ENTITY_NAME) + ->withFieldName('mailTemplateTypeId') + ->withFieldSourcePath('mailTemplateType.technicalName') ->build(UnsupportedMailTemplateTypeLog::class) ); diff --git a/src/Profile/Shopware6/Converter/MediaFolderConverter.php b/src/Profile/Shopware6/Converter/MediaFolderConverter.php index 3453c1c18..2fadd4426 100644 --- a/src/Profile/Shopware6/Converter/MediaFolderConverter.php +++ b/src/Profile/Shopware6/Converter/MediaFolderConverter.php @@ -7,6 +7,7 @@ namespace SwagMigrationAssistant\Profile\Shopware6\Converter; +use Shopware\Core\Content\Media\Aggregate\MediaFolder\MediaFolderDefinition; use Shopware\Core\Framework\Log\Package; use SwagMigrationAssistant\Migration\Converter\ConvertStruct; use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; @@ -59,8 +60,13 @@ protected function convertData(array $data): ConvertStruct $converted['parentId'] = $this->mediaFolderLookup->get($data['defaultFolder']['entity'], $this->context); if ($converted['parentId'] === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(MediaFolderDefinition::ENTITY_NAME) + ->withFieldName('parentId') + ->withFieldSourcePath('defaultFolder.entity') + ->withSourceData($data) + ->withConvertedData($converted) ->build(UnsupportedMediaDefaultFolderLog::class) ); } diff --git a/src/Profile/Shopware6/Converter/NumberRangeConverter.php b/src/Profile/Shopware6/Converter/NumberRangeConverter.php index b905eab80..6d4125a2a 100644 --- a/src/Profile/Shopware6/Converter/NumberRangeConverter.php +++ b/src/Profile/Shopware6/Converter/NumberRangeConverter.php @@ -12,6 +12,7 @@ use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter; use Shopware\Core\Framework\Log\Package; use Shopware\Core\System\NumberRange\Aggregate\NumberRangeState\NumberRangeStateCollection; +use Shopware\Core\System\NumberRange\NumberRangeDefinition; use SwagMigrationAssistant\Migration\Converter\ConvertStruct; use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; @@ -63,8 +64,12 @@ protected function convertData(array $data): ConvertStruct $data['id'] ); - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(NumberRangeDefinition::ENTITY_NAME) + ->withFieldName('typeId') + ->withFieldSourcePath('id') + ->withSourceData($data) ->build(UnsupportedNumberRangeTypeLog::class) ); diff --git a/src/Profile/Shopware6/Converter/ShopwareConverter.php b/src/Profile/Shopware6/Converter/ShopwareConverter.php index d2dcb8d2e..054364ea0 100644 --- a/src/Profile/Shopware6/Converter/ShopwareConverter.php +++ b/src/Profile/Shopware6/Converter/ShopwareConverter.php @@ -145,8 +145,10 @@ protected function updateAssociationIds(array &$associationArray, string $entity if (empty($newAssociationId)) { if ($logMissing) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName($entity) + ->withConvertedData($association) ->build(AssociationRequiredMissingLog::class) ); } diff --git a/src/Profile/Shopware6/Media/HttpOrderDocumentGenerationService.php b/src/Profile/Shopware6/Media/HttpOrderDocumentGenerationService.php index dae35f759..6dd31d313 100644 --- a/src/Profile/Shopware6/Media/HttpOrderDocumentGenerationService.php +++ b/src/Profile/Shopware6/Media/HttpOrderDocumentGenerationService.php @@ -86,7 +86,7 @@ public function process( if ($client === null) { $exception = new \Exception('Connection to the source system could not be established'); - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) ->withExceptionMessage($exception->getMessage()) ->withExceptionTrace($exception->getTrace()) @@ -287,10 +287,12 @@ private function handleFailedRequest( if ($mappedWorkload->getErrorCount() > ProcessMediaHandler::MEDIA_ERROR_THRESHOLD) { $failureUuids[] = $uuid; $mappedWorkload->setState(MediaProcessWorkloadStruct::ERROR_STATE); - $this->loggingService->addLogEntry( // TODO: add optional fields + + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) ->withExceptionMessage($clientException?->getMessage() ?? 'Unknown error occurred') ->withExceptionTrace($clientException?->getTrace() ?? []) + ->withSourceData($additionalData) ->build(CannotGetFileRunLog::class) ); } diff --git a/tests/Migration/Services/MigrationDataProcessingTest.php b/tests/Migration/Services/MigrationDataProcessingTest.php index 061ac313b..bac2ffcc1 100644 --- a/tests/Migration/Services/MigrationDataProcessingTest.php +++ b/tests/Migration/Services/MigrationDataProcessingTest.php @@ -365,7 +365,7 @@ public function testFetchInvalidCustomerData(): void ++$countInvalidLogging; } - static::assertSame(5, $countValidLogging); + static::assertSame(8, $countValidLogging); static::assertSame(0, $countInvalidLogging); $failureConvertCriteria = new Criteria(); diff --git a/tests/Profile/Shopware54/Converter/OrderDocumentConverterTest.php b/tests/Profile/Shopware54/Converter/OrderDocumentConverterTest.php index a7a69a0f2..d4c67c91f 100644 --- a/tests/Profile/Shopware54/Converter/OrderDocumentConverterTest.php +++ b/tests/Profile/Shopware54/Converter/OrderDocumentConverterTest.php @@ -15,8 +15,6 @@ use Shopware\Core\Framework\Uuid\Uuid; use SwagMigrationAssistant\Migration\Connection\SwagMigrationConnectionEntity; use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; -use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; -use SwagMigrationAssistant\Migration\Logging\Log\DocumentTypeNotSupportedLog; use SwagMigrationAssistant\Migration\Logging\LoggingServiceInterface; use SwagMigrationAssistant\Migration\Mapping\Lookup\DocumentTypeLookup; use SwagMigrationAssistant\Migration\Mapping\Lookup\MediaDefaultFolderLookup; @@ -176,14 +174,7 @@ public function testConvertShouldLogUnknownType(): void foreach ($orderDocumentConverterClasses as $orderDocumentConverterClass => $expected) { $loggerMock = $this->createMock(LoggingServiceInterface::class); - $loggerMock->expects(static::exactly(1))->method('addLogEntry')->with( - (new SwagMigrationLogBuilder( - $this->runId, - Shopware54Profile::PROFILE_NAME, - ShopwareLocalGateway::GATEWAY_NAME - ))->build(DocumentTypeNotSupportedLog::class) - ); - + $loggerMock->expects(static::exactly(1))->method('addLogEntry'); $orderDocumentConverter = $this->createDocumentConverter($orderDocumentConverterClass, $mappingServiceMock, $loggerMock); $convertResult = $orderDocumentConverter->convert( $document, diff --git a/tests/Profile/Shopware55/Converter/CustomerConverterTest.php b/tests/Profile/Shopware55/Converter/CustomerConverterTest.php index d8a76f604..69657b940 100644 --- a/tests/Profile/Shopware55/Converter/CustomerConverterTest.php +++ b/tests/Profile/Shopware55/Converter/CustomerConverterTest.php @@ -429,11 +429,12 @@ public function testConvertWithoutRequiredAddressPropertiesForDefaultBillingAndS static::assertSame($converted['addresses'][0]['id'], $converted['defaultShippingAddressId']); $logs = $this->loggingService->getLoggingArray(); - static::assertCount(3, $logs); + static::assertCount(4, $logs); static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD'); static::assertSame($logs[1]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD'); static::assertSame($logs[2]['code'], 'SWAG_MIGRATION_ENTITY_FIELD_REASSIGNED'); + static::assertSame($logs[2]['code'], 'SWAG_MIGRATION_ENTITY_FIELD_REASSIGNED'); } public function testGetCustomerWithShopScope(): void