diff --git a/.github/actions/setup-magento-plugin/action.yml b/.github/actions/setup-magento-plugin/action.yml index 5ea3af61..66b85ccb 100644 --- a/.github/actions/setup-magento-plugin/action.yml +++ b/.github/actions/setup-magento-plugin/action.yml @@ -48,6 +48,7 @@ runs: [ { "name": "SwagMigrationAssistant", + "branch": "feature/migration-logging-refactor", "repo": "https://github.com/shopware/SwagMigrationAssistant.git" } ] diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 404331f3..56e7d51a 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -34,3 +34,13 @@ parameters: - # Ignore undefined function calls on MappingServiceInterface because PHPStan dont get the inheritance message: '#Call to an undefined method SwagMigrationAssistant\\Migration\\Mapping\\MappingServiceInterface::createListItemMapping|getUuidList\(\)#' + + - # TODO remove this for 6.8 compatibility + message: '#Access to constant on deprecated class Shopware\\Core\\Checkout\\Payment\\Cart\\PaymentHandler\\DebitPayment:#' + paths: + - tests/**/*Test.php + + - # TODO remove this for 6.8 compatibility + message: '#Call to deprecated method __construct\(\) of class Shopware\\Core\\Framework\\DataAbstractionLayer\\EntityDefinition:#' + paths: + - tests/**/*Test.php diff --git a/src/Migration/Logging/FileHandleErrorLog.php b/src/Migration/Logging/FileHandleErrorLog.php index da6b4a27..5db4b21a 100644 --- a/src/Migration/Logging/FileHandleErrorLog.php +++ b/src/Migration/Logging/FileHandleErrorLog.php @@ -8,17 +8,14 @@ namespace Swag\MigrationMagento\Migration\Logging; use Shopware\Core\Framework\Log\Package; -use SwagMigrationAssistant\Migration\Logging\Log\BaseRunLogEntry; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\AbstractSwagMigrationLogEntry; #[Package('fundamentals@after-sales')] -class FileHandleErrorLog extends BaseRunLogEntry +readonly class FileHandleErrorLog extends AbstractSwagMigrationLogEntry { - public function __construct( - string $runId, - string $entity, - ?string $sourceId = null, - ) { - parent::__construct($runId, $entity, $sourceId); + public function isUserFixable(): bool + { + return false; } public function getLevel(): string @@ -30,24 +27,4 @@ public function getCode(): string { return 'SWAG_MIGRATION_MAGENTO__COULD_NOT_OPEN_FILE'; } - - public function getTitle(): string - { - return 'An exception occurred'; - } - - public function getParameters(): array - { - return [ - 'entity' => $this->getEntity(), - 'sourceId' => $this->getSourceId(), - 'exceptionCode' => $this->getCode(), - 'description' => 'Could not open file to read or write', - ]; - } - - public function getDescription(): string - { - return $this->getParameters()['description']; - } } diff --git a/src/Profile/Magento/Converter/CategoryConverter.php b/src/Profile/Magento/Converter/CategoryConverter.php index e981efd1..28de4b1d 100644 --- a/src/Profile/Magento/Converter/CategoryConverter.php +++ b/src/Profile/Magento/Converter/CategoryConverter.php @@ -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) + ); return new ConvertStruct(null, $data); } diff --git a/src/Profile/Magento/Converter/CountryConverter.php b/src/Profile/Magento/Converter/CountryConverter.php index f2f6b0d8..d277691a 100644 --- a/src/Profile/Magento/Converter/CountryConverter.php +++ b/src/Profile/Magento/Converter/CountryConverter.php @@ -51,11 +51,7 @@ public function convert(array $data, Context $context, MigrationContextInterface return new ConvertStruct(null, $data); } - $connection = $migrationContext->getConnection(); - $this->connectionId = ''; - if ($connection !== null) { - $this->connectionId = $connection->getId(); - } + $this->connectionId = $migrationContext->getConnection()->getId(); $this->generateChecksum($data); $countryMapping = $this->mappingService->getMapping($this->connectionId, DefaultEntities::COUNTRY, $data['isoCode'], $context); diff --git a/src/Profile/Magento/Converter/CrossSellingConverter.php b/src/Profile/Magento/Converter/CrossSellingConverter.php index e13589aa..7cfa1b2c 100644 --- a/src/Profile/Magento/Converter/CrossSellingConverter.php +++ b/src/Profile/Magento/Converter/CrossSellingConverter.php @@ -7,12 +7,14 @@ namespace Swag\MigrationMagento\Profile\Magento\Converter; +use Shopware\Core\Content\Product\Aggregate\ProductCrossSelling\ProductCrossSellingDefinition; use Shopware\Core\Framework\Context; use Shopware\Core\Framework\Log\Package; use Swag\MigrationMagento\Profile\Magento\DataSelection\DefaultEntities as MagentoDefaultEntities; use SwagMigrationAssistant\Migration\Converter\ConvertStruct; use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; use SwagMigrationAssistant\Migration\Logging\Log\AssociationRequiredMissingLog; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; use SwagMigrationAssistant\Migration\MigrationContextInterface; #[Package('fundamentals@after-sales')] @@ -39,11 +41,7 @@ public function convert(array $data, Context $context, MigrationContextInterface $this->oldIdentifier = $data['link_id']; $this->context = $context; - $connection = $migrationContext->getConnection(); - $this->connectionId = ''; - if ($connection !== null) { - $this->connectionId = $connection->getId(); - } + $this->connectionId = $migrationContext->getConnection()->getId(); $this->mainMapping = $this->mappingService->getOrCreateMapping( $this->connectionId, @@ -64,12 +62,15 @@ public function convert(array $data, Context $context, MigrationContextInterface ); if ($sourceProductMapping === null) { - $this->loggingService->addLogEntry(new AssociationRequiredMissingLog( - $this->runId, - DefaultEntities::PRODUCT, - $data['sourceProductId'], - $data['type'] - )); + $this->loggingService->addLogEntry( + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(ProductCrossSellingDefinition::ENTITY_NAME) + ->withFieldName('productId') + ->withFieldSourcePath('sourceProductId') + ->withSourceData($data) + ->withConvertedData($converted) + ->build(AssociationRequiredMissingLog::class) + ); return new ConvertStruct(null, $data); } @@ -83,12 +84,15 @@ public function convert(array $data, Context $context, MigrationContextInterface ); if ($relatedProductMapping === null) { - $this->loggingService->addLogEntry(new AssociationRequiredMissingLog( - $this->runId, - DefaultEntities::PRODUCT, - $data['linked_product_id'], - $data['type'] - )); + $this->loggingService->addLogEntry( + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(ProductCrossSellingDefinition::ENTITY_NAME) + ->withFieldName('productId') + ->withFieldSourcePath('linked_product_id') + ->withSourceData($data) + ->withConvertedData($converted) + ->build(AssociationRequiredMissingLog::class) + ); return new ConvertStruct(null, $data); } diff --git a/src/Profile/Magento/Converter/CurrencyConverter.php b/src/Profile/Magento/Converter/CurrencyConverter.php index 98d0ba78..92f8737e 100644 --- a/src/Profile/Magento/Converter/CurrencyConverter.php +++ b/src/Profile/Magento/Converter/CurrencyConverter.php @@ -55,11 +55,7 @@ public function convert(array $data, Context $context, MigrationContextInterface } unset($data['isoCode']); - $connection = $migrationContext->getConnection(); - $this->connectionId = ''; - if ($connection !== null) { - $this->connectionId = $connection->getId(); - } + $this->connectionId = $migrationContext->getConnection()->getId(); $this->generateChecksum($data); diff --git a/src/Profile/Magento/Converter/CustomFieldConverter.php b/src/Profile/Magento/Converter/CustomFieldConverter.php index 9d5d6ad6..d6058884 100644 --- a/src/Profile/Magento/Converter/CustomFieldConverter.php +++ b/src/Profile/Magento/Converter/CustomFieldConverter.php @@ -9,10 +9,12 @@ use Shopware\Core\Framework\Context; use Shopware\Core\Framework\Log\Package; +use Shopware\Core\System\CustomField\CustomFieldDefinition; use SwagMigrationAssistant\Migration\Converter\Converter; use SwagMigrationAssistant\Migration\Converter\ConvertStruct; use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; use SwagMigrationAssistant\Migration\Logging\Log\AssociationRequiredMissingLog; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; use SwagMigrationAssistant\Migration\MigrationContextInterface; #[Package('fundamentals@after-sales')] @@ -46,11 +48,7 @@ public function convert(array $data, Context $context, MigrationContextInterface $this->migrationContext = $migrationContext; $type = $this->validateType($data); - $connection = $migrationContext->getConnection(); - $this->connectionId = ''; - if ($connection !== null) { - $this->connectionId = $connection->getId(); - } + $this->connectionId = $migrationContext->getConnection()->getId(); $entityName = $this->getDataSetEntity($migrationContext); @@ -67,12 +65,12 @@ public function convert(array $data, Context $context, MigrationContextInterface if ($defaultLocale === null) { $this->loggingService->addLogEntry( - new AssociationRequiredMissingLog( - $migrationContext->getRunUuid(), - DefaultEntities::LOCALE, - 'global_default', - DefaultEntities::CUSTOM_FIELD_SET - ) + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(CustomFieldDefinition::ENTITY_NAME) + ->withFieldName('locale') + ->withFieldSourcePath('global_default') + ->withSourceData($data) + ->build(AssociationRequiredMissingLog::class) ); return new ConvertStruct(null, $data); diff --git a/src/Profile/Magento/Converter/CustomerConverter.php b/src/Profile/Magento/Converter/CustomerConverter.php index 8fbf3c8b..6269198a 100644 --- a/src/Profile/Magento/Converter/CustomerConverter.php +++ b/src/Profile/Magento/Converter/CustomerConverter.php @@ -7,6 +7,8 @@ namespace Swag\MigrationMagento\Profile\Magento\Converter; +use Shopware\Core\Checkout\Customer\Aggregate\CustomerAddress\CustomerAddressDefinition; +use Shopware\Core\Checkout\Customer\CustomerDefinition; use Shopware\Core\Framework\Context; use Shopware\Core\Framework\Log\Package; use Shopware\Core\System\NumberRange\ValueGenerator\NumberRangeValueGeneratorInterface; @@ -16,6 +18,7 @@ use Swag\MigrationMagento\Profile\Magento\Premapping\PaymentMethodReader; 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\Log\FieldReassignedRunLog; use SwagMigrationAssistant\Migration\Logging\Log\UnknownEntityLog; @@ -88,13 +91,16 @@ public function getSourceIdentifier(array $data): string public function convert(array $data, Context $context, MigrationContextInterface $migrationContext): ConvertStruct { $fields = $this->checkForEmptyRequiredDataFields($data, self::$requiredDataFieldKeys); + if (!empty($fields)) { - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $migrationContext->getRunUuid(), - DefaultEntities::CUSTOMER, - $data['entity_id'], - \implode(',', $fields) - )); + $this->loggingService->addLogForEach( + $fields, + fn (string $key) => SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(CustomerDefinition::ENTITY_NAME) + ->withFieldSourcePath($key) + ->withSourceData($data) + ->build(EmptyNecessaryFieldRunLog::class) + ); return new ConvertStruct(null, $data); } @@ -110,12 +116,7 @@ public function convert(array $data, Context $context, MigrationContextInterface $this->context = $context; unset($data['entity_id']); - $connection = $migrationContext->getConnection(); - $this->connectionId = ''; - if ($connection !== null) { - $this->connectionId = $connection->getId(); - } - + $this->connectionId = $migrationContext->getConnection()->getId(); /* * Set main mapping */ @@ -155,12 +156,15 @@ public function convert(array $data, Context $context, MigrationContextInterface } if (empty($converted['salesChannelId'])) { - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $this->runId, - DefaultEntities::CUSTOMER, - $this->oldIdentifier, - 'salesChannelId' - )); + $this->loggingService->addLogEntry( + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(CustomerDefinition::ENTITY_NAME) + ->withFieldName('salesChannelId') + ->withFieldSourcePath('store_id') + ->withSourceData($data) + ->withConvertedData($converted) + ->build(EmptyNecessaryFieldRunLog::class) + ); return new ConvertStruct(null, $this->originalData); } @@ -199,12 +203,15 @@ public function convert(array $data, Context $context, MigrationContextInterface ); if ($mapping === null) { - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $this->runId, - DefaultEntities::CUSTOMER, - $this->oldIdentifier, - 'salutation' - )); + $this->loggingService->addLogEntry( + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(CustomerDefinition::ENTITY_NAME) + ->withFieldName('salutationId') + ->withFieldSourcePath('default_salutation') + ->withSourceData($data) + ->withConvertedData($converted) + ->build(EmptyNecessaryFieldRunLog::class) + ); return new ConvertStruct(null, $data); } @@ -253,12 +260,15 @@ public function convert(array $data, Context $context, MigrationContextInterface if (!isset($converted['defaultBillingAddressId'], $converted['defaultShippingAddressId'])) { $this->mappingService->deleteMapping($converted['id'], $this->connectionId, $this->context); - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $this->runId, - DefaultEntities::CUSTOMER, - $this->oldIdentifier, - 'address data' - )); + $this->loggingService->addLogForEach( + ['default_billing_address_id', 'default_shipping_address_id'], + fn (string $key) => SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(CustomerDefinition::ENTITY_NAME) + ->withFieldName($key) + ->withSourceData($data) + ->withConvertedData($converted) + ->build(EmptyNecessaryFieldRunLog::class) + ); return new ConvertStruct(null, $this->originalData); } @@ -299,15 +309,18 @@ protected function getAddresses(array &$originalData, array &$converted, string $addresses = []; foreach ($originalData['addresses'] as $address) { $newAddress = []; - $fields = $this->checkForEmptyRequiredDataFields($address, self::$requiredAddressDataFieldKeys); + if (!empty($fields)) { - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $this->runId, - DefaultEntities::CUSTOMER_ADDRESS, - $address['entity_id'], - \implode(',', $fields) - )); + $this->loggingService->addLogForEach( + $fields, + fn (string $key) => SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(CustomerDefinition::ENTITY_NAME) + ->withFieldSourcePath($key) + ->withSourceData($address) + ->withConvertedData($converted) + ->build(EmptyNecessaryFieldRunLog::class) + ); continue; } @@ -335,15 +348,15 @@ protected function getAddresses(array &$originalData, array &$converted, string $newAddress['customerId'] = $customerUuid; $countryUuid = $this->countryLookup->getByIso3($address['country_iso3'], $this->context); + if ($countryUuid === null) { $this->loggingService->addLogEntry( - new UnknownEntityLog( - $this->runId, - DefaultEntities::COUNTRY, - $address['country_id'], - DefaultEntities::CUSTOMER, - $this->oldIdentifier - ) + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(CustomerAddressDefinition::ENTITY_NAME) + ->withFieldName('countryId') + ->withFieldSourcePath('country_iso3') + ->withSourceData($addresses) + ->build(UnknownEntityLog::class) ); continue; @@ -377,13 +390,13 @@ protected function getAddresses(array &$originalData, array &$converted, string ]; } else { $this->loggingService->addLogEntry( - new UnknownEntityLog( - $this->runId, - DefaultEntities::COUNTRY_STATE, - $address['region_id'], - DefaultEntities::CUSTOMER, - $this->oldIdentifier - ) + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(CustomerAddressDefinition::ENTITY_NAME) + ->withFieldName('countryState') + ->withFieldSourcePath('region') + ->withSourceData($originalData) + ->withConvertedData($converted) + ->build(UnknownEntityLog::class) ); } } @@ -422,13 +435,19 @@ protected function checkUnsetDefaultShippingAndDefaultBillingAddress(array &$ori $converted['defaultShippingAddressId'] = $addresses[0]['id']; unset($originalData['default_billing_address_id'], $originalData['default_shipping_address_id']); - $this->loggingService->addLogEntry(new FieldReassignedRunLog( - $this->runId, - DefaultEntities::CUSTOMER, - $this->oldIdentifier, - 'default billing and shipping address', - 'first address' - )); + $this->loggingService->addLogForEach( + [ + 'defaultBillingAddressId' => 'default_billing_address_id', + 'defaultShippingAddressId' => 'default_shipping_address_id', + ], + fn (string $key, string $value) => SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(CustomerDefinition::ENTITY_NAME) + ->withFieldName($key) + ->withFieldSourcePath($value) + ->withSourceData($originalData) + ->withConvertedData($converted) + ->build(FieldReassignedRunLog::class) + ); } } @@ -438,13 +457,15 @@ protected function checkUnsetDefaultShippingAddress(array &$originalData, array $converted['defaultShippingAddressId'] = $converted['defaultBillingAddressId']; unset($originalData['default_shipping_address_id']); - $this->loggingService->addLogEntry(new FieldReassignedRunLog( - $this->runId, - DefaultEntities::CUSTOMER, - $this->oldIdentifier, - 'default shipping address', - 'default billing address' - )); + $this->loggingService->addLogEntry( + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(CustomerDefinition::ENTITY_NAME) + ->withFieldName('defaultShippingAddressId') + ->withFieldSourcePath('default_shipping_address_id') + ->withSourceData($originalData) + ->withConvertedData($converted) + ->build(FieldReassignedRunLog::class) + ); } } @@ -454,13 +475,15 @@ protected function checkUnsetDefaultBillingAddress(array &$originalData, array & $converted['defaultBillingAddressId'] = $converted['defaultShippingAddressId']; unset($originalData['default_billing_address_id']); - $this->loggingService->addLogEntry(new FieldReassignedRunLog( - $this->runId, - DefaultEntities::CUSTOMER, - $this->oldIdentifier, - 'default billing address', - 'default shipping address' - )); + $this->loggingService->addLogEntry( + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(CustomerDefinition::ENTITY_NAME) + ->withFieldName('defaultBillingAddressId') + ->withFieldSourcePath('default_shipping_address_id') + ->withSourceData($originalData) + ->withConvertedData($converted) + ->build(FieldReassignedRunLog::class) + ); } } @@ -482,13 +505,16 @@ protected function getSalutation(string $gender): ?string ); if ($mapping === null) { - $this->loggingService->addLogEntry(new UnknownEntityLog( - $this->runId, - DefaultEntities::SALUTATION, - $gender, - DefaultEntities::CUSTOMER, - $this->oldIdentifier - )); + $this->loggingService->addLogEntry( + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(CustomerDefinition::ENTITY_NAME) + ->withFieldName('salutationId') + ->withFieldSourcePath('gender') + ->withSourceData([ + 'gender' => $gender, + ]) + ->build(UnknownEntityLog::class) + ); return null; } @@ -508,13 +534,13 @@ protected function getDefaultPaymentMethod(): ?string ); if ($paymentMethodMapping === null) { - $this->loggingService->addLogEntry(new UnknownEntityLog( - $this->runId, - DefaultEntities::PAYMENT_METHOD, - 'default_payment_method', - DefaultEntities::CUSTOMER, - $this->oldIdentifier - )); + $this->loggingService->addLogEntry( + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(CustomerDefinition::ENTITY_NAME) + ->withFieldName('defaultPaymentMethodId') + ->withFieldSourcePath('default_payment_method') + ->build(UnknownEntityLog::class) + ); return null; } diff --git a/src/Profile/Magento/Converter/CustomerGroupConverter.php b/src/Profile/Magento/Converter/CustomerGroupConverter.php index 4d3e8c23..766ea98c 100644 --- a/src/Profile/Magento/Converter/CustomerGroupConverter.php +++ b/src/Profile/Magento/Converter/CustomerGroupConverter.php @@ -29,12 +29,7 @@ public function convert(array $data, Context $context, MigrationContextInterface { $this->generateChecksum($data); $this->context = $context; - - $connection = $migrationContext->getConnection(); - $this->connectionId = ''; - if ($connection !== null) { - $this->connectionId = $connection->getId(); - } + $this->connectionId = $migrationContext->getConnection()->getId(); $this->mainMapping = $this->mappingService->getOrCreateMapping( $this->connectionId, diff --git a/src/Profile/Magento/Converter/LanguageConverter.php b/src/Profile/Magento/Converter/LanguageConverter.php index 36764684..c913884c 100644 --- a/src/Profile/Magento/Converter/LanguageConverter.php +++ b/src/Profile/Magento/Converter/LanguageConverter.php @@ -55,12 +55,7 @@ public function convert(array $data, Context $context, MigrationContextInterface $this->migrationContext = $migrationContext; $this->oldIdentifier = $data['locale']; $this->context = $context; - - $connection = $migrationContext->getConnection(); - $this->connectionId = ''; - if ($connection !== null) { - $this->connectionId = $connection->getId(); - } + $this->connectionId = $migrationContext->getConnection()->getId(); $languageUuid = $this->languageLookup->get($this->oldIdentifier, $context); if ($languageUuid !== null) { diff --git a/src/Profile/Magento/Converter/MagentoConverter.php b/src/Profile/Magento/Converter/MagentoConverter.php index 6b857fb2..8bbf532b 100644 --- a/src/Profile/Magento/Converter/MagentoConverter.php +++ b/src/Profile/Magento/Converter/MagentoConverter.php @@ -142,15 +142,11 @@ protected function getAttributes(array $attributes, int $attributeSetId, array $ protected function getTranslations(array $translations, array $defaultEntities, Context $context, ?int $attributeSetId = null): array { - $connection = $this->migrationContext->getConnection(); - if ($connection === null) { - return []; - } - $localeTranslation = []; + foreach ($translations as $store => $translationValues) { $languageMapping = $this->mappingService->getMapping( - $connection->getId(), + $this->migrationContext->getConnection()->getId(), DefaultEntities::STORE_LANGUAGE, (string) $store, $context diff --git a/src/Profile/Magento/Converter/ManufacturerConverter.php b/src/Profile/Magento/Converter/ManufacturerConverter.php index 7a121ea9..aaaf3cb5 100644 --- a/src/Profile/Magento/Converter/ManufacturerConverter.php +++ b/src/Profile/Magento/Converter/ManufacturerConverter.php @@ -50,12 +50,7 @@ public function convert(array $data, Context $context, MigrationContextInterface $this->migrationContext = $migrationContext; $this->oldIdentifier = $data['option_id']; $this->context = $context; - - $connection = $migrationContext->getConnection(); - $this->connectionId = ''; - if ($connection !== null) { - $this->connectionId = $connection->getId(); - } + $this->connectionId = $migrationContext->getConnection()->getId(); $this->mainMapping = $this->mappingService->getOrCreateMapping( $this->connectionId, diff --git a/src/Profile/Magento/Converter/MediaConverter.php b/src/Profile/Magento/Converter/MediaConverter.php index 00ce8c3b..b88f0cb7 100644 --- a/src/Profile/Magento/Converter/MediaConverter.php +++ b/src/Profile/Magento/Converter/MediaConverter.php @@ -59,11 +59,7 @@ public function getMediaUuids(array $converted): ?array public function convert(array $data, Context $context, MigrationContextInterface $migrationContext): ConvertStruct { $this->generateChecksum($data); - $connection = $migrationContext->getConnection(); - $this->connectionId = ''; - if ($connection !== null) { - $this->connectionId = $connection->getId(); - } + $this->connectionId = $migrationContext->getConnection()->getId(); $converted = []; $this->mainMapping = $this->mappingService->getOrCreateMapping( diff --git a/src/Profile/Magento/Converter/NewsletterRecipientConverter.php b/src/Profile/Magento/Converter/NewsletterRecipientConverter.php index a6e5167f..ed84c10a 100644 --- a/src/Profile/Magento/Converter/NewsletterRecipientConverter.php +++ b/src/Profile/Magento/Converter/NewsletterRecipientConverter.php @@ -7,6 +7,7 @@ namespace Swag\MigrationMagento\Profile\Magento\Converter; +use Shopware\Core\Content\Newsletter\Aggregate\NewsletterRecipient\NewsletterRecipientDefinition; use Shopware\Core\Framework\Context; use Shopware\Core\Framework\Log\Package; use Swag\MigrationMagento\Profile\Magento\DataSelection\DefaultEntities as MagentoDefaultEntities; @@ -14,6 +15,7 @@ use SwagMigrationAssistant\Migration\Converter\ConvertStruct; use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; use SwagMigrationAssistant\Migration\Logging\Log\AssociationRequiredMissingLog; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; use SwagMigrationAssistant\Migration\Logging\Log\EmptyNecessaryFieldRunLog; use SwagMigrationAssistant\Migration\MigrationContextInterface; @@ -39,12 +41,7 @@ public function convert(array $data, Context $context, MigrationContextInterface $this->context = $context; $this->runId = $migrationContext->getRunUuid(); $this->originalData = $data; - - $connection = $migrationContext->getConnection(); - $this->connectionId = ''; - if ($connection !== null) { - $this->connectionId = $connection->getId(); - } + $this->connectionId = $migrationContext->getConnection()->getId(); $converted = []; $languageMapping = $this->mappingService->getMapping( @@ -55,12 +52,13 @@ public function convert(array $data, Context $context, MigrationContextInterface ); if ($languageMapping === null) { - $this->loggingService->addLogEntry(new AssociationRequiredMissingLog( - $migrationContext->getRunUuid(), - DefaultEntities::LANGUAGE, - $data['store_id'], - DefaultEntities::NEWSLETTER_RECIPIENT - )); + $this->loggingService->addLogEntry( + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(NewsletterRecipientDefinition::ENTITY_NAME) + ->withFieldName('languageId') + ->withSourceData($data) + ->build(AssociationRequiredMissingLog::class) + ); return new ConvertStruct(null, $data); } @@ -76,10 +74,12 @@ public function convert(array $data, Context $context, MigrationContextInterface $converted['languageId'] = $languageMapping['entityUuid']; $converted['hash'] = $data['subscriber_confirm_code']; - $salesChannelMapping = $this->getSalesChannelMapping($data); + $salesChannelMapping = $this->getSalesChannelMapping($data, $migrationContext); + if ($salesChannelMapping === null) { return new ConvertStruct(null, $this->originalData); } + $this->mappingIds[] = $salesChannelMapping['id']; $converted['salesChannelId'] = $salesChannelMapping['entityUuid']; @@ -94,12 +94,14 @@ public function convert(array $data, Context $context, MigrationContextInterface if (isset($data['title'])) { $this->convertValue($converted, 'title', $data, 'title'); } - $status = $this->getStatus($data); + + $status = $this->getStatus($data, $migrationContext); + if ($status === null) { return new ConvertStruct(null, $this->originalData); } - $converted['status'] = $status; + $converted['status'] = $status; $this->updateMainMapping($migrationContext, $context); unset( @@ -119,7 +121,7 @@ public function convert(array $data, Context $context, MigrationContextInterface return new ConvertStruct($converted, $resultData, $this->mainMapping['id'] ?? null); } - private function getSalesChannelMapping(array $data): ?array + private function getSalesChannelMapping(array $data, MigrationContextInterface $migrationContext): ?array { $salesChannelMapping = $this->mappingService->getMapping( $this->connectionId, @@ -129,18 +131,20 @@ private function getSalesChannelMapping(array $data): ?array ); if ($salesChannelMapping === null) { - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $this->runId, - DefaultEntities::NEWSLETTER_RECIPIENT, - $data['subscriber_id'], - 'salesChannel' - )); + $this->loggingService->addLogEntry( + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(NewsletterRecipientDefinition::ENTITY_NAME) + ->withFieldName('salesChannelId') + ->withFieldSourcePath('store_id') + ->withSourceData($this->originalData) + ->build(EmptyNecessaryFieldRunLog::class) + ); } return $salesChannelMapping; } - private function getStatus(array $data): ?string + private function getStatus(array $data, MigrationContextInterface $migrationContext): ?string { $status = $this->mappingService->getValue( $this->connectionId, @@ -159,12 +163,14 @@ private function getStatus(array $data): ?string } if ($status === null) { - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $this->runId, - DefaultEntities::NEWSLETTER_RECIPIENT, - $data['subscriber_id'], - 'status' - )); + $this->loggingService->addLogEntry( + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(NewsletterRecipientDefinition::ENTITY_NAME) + ->withFieldName('status') + ->withFieldSourcePath('default_newsletter_recipient_status') + ->withSourceData($data) + ->build(EmptyNecessaryFieldRunLog::class) + ); } return $status; diff --git a/src/Profile/Magento/Converter/NotAssociatedMediaConverter.php b/src/Profile/Magento/Converter/NotAssociatedMediaConverter.php index c5bc0c78..8cb423fa 100644 --- a/src/Profile/Magento/Converter/NotAssociatedMediaConverter.php +++ b/src/Profile/Magento/Converter/NotAssociatedMediaConverter.php @@ -55,11 +55,7 @@ public function getMediaUuids(array $converted): ?array public function convert(array $data, Context $context, MigrationContextInterface $migrationContext): ConvertStruct { $this->generateChecksum($data); - $connection = $migrationContext->getConnection(); - $this->connectionId = ''; - if ($connection !== null) { - $this->connectionId = $connection->getId(); - } + $this->connectionId = $migrationContext->getConnection()->getId(); $converted = []; $this->mainMapping = $this->mappingService->getOrCreateMapping( diff --git a/src/Profile/Magento/Converter/OrderConverter.php b/src/Profile/Magento/Converter/OrderConverter.php index aec2b2e4..ec03c613 100644 --- a/src/Profile/Magento/Converter/OrderConverter.php +++ b/src/Profile/Magento/Converter/OrderConverter.php @@ -16,7 +16,14 @@ 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\Customer\CustomerDefinition; +use Shopware\Core\Checkout\Order\Aggregate\OrderAddress\OrderAddressDefinition; +use Shopware\Core\Checkout\Order\Aggregate\OrderCustomer\OrderCustomerDefinition; +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\Aggregate\OrderTransaction\OrderTransactionStates; +use Shopware\Core\Checkout\Order\OrderDefinition; use Shopware\Core\Framework\Context; use Shopware\Core\Framework\Log\Package; use Shopware\Core\Framework\Util\Hasher; @@ -33,6 +40,7 @@ use SwagMigrationAssistant\Migration\Converter\ConvertStruct; use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; use SwagMigrationAssistant\Migration\Logging\Log\AssociationRequiredMissingLog; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; use SwagMigrationAssistant\Migration\Logging\Log\EmptyNecessaryFieldRunLog; use SwagMigrationAssistant\Migration\Logging\Log\UnknownEntityLog; use SwagMigrationAssistant\Migration\Logging\LoggingServiceInterface; @@ -119,12 +127,14 @@ public function convert(array $data, Context $context, MigrationContextInterface } if (!empty($fields)) { - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $migrationContext->getRunUuid(), - DefaultEntities::ORDER, - $data['identifier'], - \implode(',', $fields) - )); + $this->loggingService->addLogForEach( + $fields, + fn (string $key) => SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(OrderDefinition::ENTITY_NAME) + ->withFieldSourcePath($key) + ->withSourceData($data) + ->build(EmptyNecessaryFieldRunLog::class) + ); return new ConvertStruct(null, $data); } @@ -138,20 +148,17 @@ public function convert(array $data, Context $context, MigrationContextInterface $this->migrationContext = $migrationContext; $this->context = $context; $this->oldIdentifier = $data['orders']['entity_id']; - - $connection = $migrationContext->getConnection(); - $this->connectionId = ''; - if ($connection !== null) { - $this->connectionId = $connection->getId(); - } + $this->connectionId = $migrationContext->getConnection()->getId(); if (!$this->oldIdentifier) { - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $migrationContext->getRunUuid(), - DefaultEntities::ORDER, - $data['identifier'], - 'entity_id' - )); + $this->loggingService->addLogEntry( + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(OrderDefinition::ENTITY_NAME) + ->withFieldName('id') + ->withFieldSourcePath('orders.entity_id') + ->withSourceData($data) + ->build(EmptyNecessaryFieldRunLog::class) + ); return new ConvertStruct(null, $data); } @@ -186,19 +193,25 @@ public function convert(array $data, Context $context, MigrationContextInterface if (!isset($converted['salesChannelId'])) { if (isset($data['orders']['store_id'])) { - $this->loggingService->addLogEntry(new AssociationRequiredMissingLog( - $this->runId, - MagentoDefaultEntities::STORE, - $data['orders']['store_id'], - DefaultEntities::ORDER - )); + $this->loggingService->addLogEntry( + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(OrderDefinition::ENTITY_NAME) + ->withFieldName('salesChannelId') + ->withFieldSourcePath('orders.store_id') + ->withSourceData($data) + ->withConvertedData($converted) + ->build(AssociationRequiredMissingLog::class) + ); } else { - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $this->runId, - DefaultEntities::ORDER, - $this->oldIdentifier, - 'store_id' - )); + $this->loggingService->addLogEntry( + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(OrderDefinition::ENTITY_NAME) + ->withFieldName('salesChannelId') + ->withFieldSourcePath('orders.store_id') + ->withSourceData($data) + ->withConvertedData($converted) + ->build(EmptyNecessaryFieldRunLog::class) + ); } return new ConvertStruct(null, $this->originalData); @@ -279,13 +292,16 @@ protected function getSalutation(string $salutation): ?string ); if ($salutationMapping === null) { - $this->loggingService->addLogEntry(new UnknownEntityLog( - $this->runId, - DefaultEntities::SALUTATION, - $salutation, - DefaultEntities::CUSTOMER, - $this->oldIdentifier - )); + $this->loggingService->addLogEntry( + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(OrderDefinition::ENTITY_NAME) + ->withFieldName('salutationId') + ->withFieldSourcePath('default_salutation') + ->withSourceData([ + 'salutationId' => $salutation, + ]) + ->build(UnknownEntityLog::class) + ); return null; } @@ -409,12 +425,15 @@ protected function getLineItems(array $originalData, Context $context, Calculate } if (!isset($lineItem['identifier'])) { - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $this->runId, - DefaultEntities::ORDER_LINE_ITEM, - $originalLineItem['item_id'], - 'identifier' - )); + $this->loggingService->addLogEntry( + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(OrderLineItemDefinition::ENTITY_NAME) + ->withFieldName('id') + ->withFieldSourcePath('identifier') + ->withSourceData($lineItem) + ->withUsedMapping($mapping ?? []) + ->build(EmptyNecessaryFieldRunLog::class) + ); continue; } @@ -451,13 +470,15 @@ protected function getDeliveries(array $data, array $converted): array ); if ($deliveryStateMapping === null) { - $this->loggingService->addLogEntry(new UnknownEntityLog( - $this->runId, - DefaultEntities::STATE_MACHINE_STATE, - MagentoOrderDeliveryStateReader::DEFAULT_SHIPPED_STATUS, - DefaultEntities::ORDER_DELIVERY, - $shipment['entity_id'] - )); + $this->loggingService->addLogEntry( + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(OrderDeliveryDefinition::ENTITY_NAME) + ->withFieldName('stateId') + ->withFieldSourcePath(MagentoOrderDeliveryStateReader::DEFAULT_SHIPPED_STATUS) + ->withSourceData($data) + ->withConvertedData($converted) + ->build(UnknownEntityLog::class) + ); continue; } @@ -473,12 +494,16 @@ protected function getDeliveries(array $data, array $converted): array } if (!isset($delivery['shippingMethodId'])) { - $this->loggingService->addLogEntry(new AssociationRequiredMissingLog( - $this->runId, - DefaultEntities::SHIPPING_METHOD, - $data['orders']['shipping_method'], - DefaultEntities::ORDER - )); + $this->loggingService->addLogEntry( + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(OrderDeliveryDefinition::ENTITY_NAME) + ->withFieldName('shippingMethodId') + ->withFieldSourcePath('orders.shipping_method') + ->withSourceData($data) + ->withConvertedData($converted) + ->withUsedMapping($deliveryStateMapping) + ->build(AssociationRequiredMissingLog::class) + ); continue; } @@ -568,13 +593,14 @@ protected function getShippingMethod(string $shippingMethodId): ?string ); if ($shippingMethodMapping === null) { - $this->loggingService->addLogEntry(new UnknownEntityLog( - $this->runId, - DefaultEntities::SHIPPING_METHOD, - $shippingMethodId, - DefaultEntities::ORDER, - $this->oldIdentifier - )); + $this->loggingService->addLogEntry( + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(OrderDeliveryDefinition::ENTITY_NAME) + ->withFieldName('shippingMethodId') + ->withFieldSourcePath('orders.shipping_method') + ->withSourceData($this->originalData) + ->build(UnknownEntityLog::class) + ); return null; } @@ -601,26 +627,30 @@ protected function getAddress(array $originalData, string $entityName = DefaultE $address['id'] = $mapping['entityUuid']; if (!isset($originalData['country_id']) || !isset($originalData['country_iso2']) || !isset($originalData['country_iso3'])) { - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $this->runId, - DefaultEntities::ORDER, - $this->oldIdentifier, - 'country_id, country_iso2, country_iso3' - )); + $this->loggingService->addLogEntry( + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(OrderAddressDefinition::ENTITY_NAME) + ->withFieldName('countryId') + ->withFieldSourcePath('country_id, country_iso2, country_iso3') + ->withSourceData($originalData) + ->withUsedMapping($mapping) + ->build(EmptyNecessaryFieldRunLog::class) + ); return []; } $countryUuid = $this->countryLookup->getByIso3($originalData['country_iso3'], $this->context); + if ($countryUuid === null) { $this->loggingService->addLogEntry( - new UnknownEntityLog( - $this->runId, - DefaultEntities::COUNTRY, - $originalData['country_id'], - DefaultEntities::ORDER, - $this->oldIdentifier - ) + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(OrderAddressDefinition::ENTITY_NAME) + ->withFieldName('countryId') + ->withFieldSourcePath('country_iso3') + ->withSourceData($originalData) + ->withUsedMapping($mapping) + ->build(UnknownEntityLog::class) ); return []; @@ -654,13 +684,13 @@ protected function getAddress(array $originalData, string $entityName = DefaultE ]; } else { $this->loggingService->addLogEntry( - new UnknownEntityLog( - $this->runId, - DefaultEntities::COUNTRY_STATE, - $originalData['region_id'], - DefaultEntities::ORDER, - $this->oldIdentifier - ) + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(OrderAddressDefinition::ENTITY_NAME) + ->withFieldName('countryState') + ->withFieldSourcePath('region') + ->withSourceData($originalData) + ->withUsedMapping($mapping) + ->build(UnknownEntityLog::class) ); } } @@ -704,7 +734,7 @@ protected function getTransactions(array $data, array &$converted): void return; } - $paymentMethodUuid = $this->getPaymentMethod($data); + $paymentMethodUuid = $this->getPaymentMethod($data, OrderTransactionDefinition::ENTITY_NAME); if ($paymentMethodUuid === null) { return; } @@ -735,7 +765,7 @@ protected function getTransactions(array $data, array &$converted): void $converted['transactions'] = $transactions; } - protected function getPaymentMethod(array $originalData): ?string + protected function getPaymentMethod(array $originalData, string $rootDefinition = OrderDefinition::ENTITY_NAME): ?string { if (!isset($originalData['orders']['payment']['method'])) { return null; @@ -749,13 +779,14 @@ protected function getPaymentMethod(array $originalData): ?string ); if ($paymentMethodMapping === null) { - $this->loggingService->addLogEntry(new UnknownEntityLog( - $this->runId, - 'payment_method', - $originalData['orders']['payment']['method'], - DefaultEntities::ORDER_TRANSACTION, - $this->oldIdentifier - )); + $this->loggingService->addLogEntry( + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName($rootDefinition) + ->withFieldName('paymentMethodId') + ->withFieldSourcePath('orders.payment.method') + ->withSourceData($originalData) + ->build(UnknownEntityLog::class) + ); return null; } @@ -774,12 +805,15 @@ protected function convertOrderCustomer(array &$converted, array &$data): bool $fields = $this->checkForEmptyRequiredDataFields($data['orders'], self::$requiredCustomerDataFieldKeys); if (!empty($fields)) { - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $this->runId, - DefaultEntities::ORDER, - $data['identifier'], - \implode(',', $fields) - )); + $this->loggingService->addLogForEach( + $fields, + fn (string $key) => SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(OrderDefinition::ENTITY_NAME) + ->withFieldSourcePath($key) + ->withSourceData($data) + ->withConvertedData($converted) + ->build(EmptyNecessaryFieldRunLog::class) + ); return false; } @@ -844,12 +878,16 @@ protected function convertOrderCustomer(array &$converted, array &$data): bool ); if ($mapping === null || !isset($mapping['entityUuid'], $mapping['id'])) { - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $this->runId, - DefaultEntities::ORDER, - $this->oldIdentifier, - 'salutation' - )); + $this->loggingService->addLogEntry( + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(OrderCustomerDefinition::ENTITY_NAME) + ->withFieldName('salutationId') + ->withFieldSourcePath('default_salutation') + ->withSourceData($data) + ->withConvertedData($converted) + ->withUsedMapping($mapping ?? []) + ->build(EmptyNecessaryFieldRunLog::class) + ); return false; } @@ -872,12 +910,15 @@ protected function convertOrderCustomer(array &$converted, array &$data): bool ); if ($customerGroupMapping === null) { - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $this->runId, - DefaultEntities::ORDER, - $this->oldIdentifier, - 'customer_group_id' - )); + $this->loggingService->addLogEntry( + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(CustomerDefinition::ENTITY_NAME) + ->withFieldName('customerGroupId') + ->withFieldSourcePath('orders.customer_group_id') + ->withSourceData($data) + ->withConvertedData($converted) + ->build(EmptyNecessaryFieldRunLog::class) + ); return false; } @@ -907,12 +948,15 @@ protected function convertOrderCustomer(array &$converted, array &$data): bool $billingAddress = $this->getAddress($data['billingAddress'], DefaultEntities::CUSTOMER_ADDRESS); if (empty($billingAddress)) { - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $this->runId, - DefaultEntities::ORDER, - $this->oldIdentifier, - 'billingAddress' - )); + $this->loggingService->addLogEntry( + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(CustomerDefinition::ENTITY_NAME) + ->withFieldName('defaultBillingAddressId') + ->withFieldSourcePath('billingAddress') + ->withSourceData($data) + ->withConvertedData($converted) + ->build(EmptyNecessaryFieldRunLog::class) + ); return false; } @@ -954,12 +998,15 @@ protected function convertCurrency(array &$converted, array &$data): bool $currencyUuid = $this->currencyLookup->get($data['orders']['order_currency_code'], $this->context); } if ($currencyUuid === null) { - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $this->runId, - DefaultEntities::ORDER, - $this->oldIdentifier, - 'currency' - )); + $this->loggingService->addLogEntry( + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(OrderDefinition::ENTITY_NAME) + ->withFieldName('currencyId') + ->withFieldSourcePath('orders.order_currency_code') + ->withSourceData($data) + ->withConvertedData($converted) + ->build(EmptyNecessaryFieldRunLog::class) + ); return false; } @@ -978,13 +1025,15 @@ protected function convertOrderStatus(array &$converted, array &$data): bool ); if ($stateMapping === null) { - $this->loggingService->addLogEntry(new UnknownEntityLog( - $this->runId, - 'order_state', - (string) $data['orders']['status'], - DefaultEntities::ORDER, - $this->oldIdentifier - )); + $this->loggingService->addLogEntry( + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(OrderDefinition::ENTITY_NAME) + ->withFieldName('stateId') + ->withFieldSourcePath('orders.status') + ->withSourceData($data) + ->withConvertedData($converted) + ->build(UnknownEntityLog::class) + ); return false; } @@ -1055,13 +1104,17 @@ protected function convertOrderItems(array &$converted, array &$data): void protected function convertBillingAddress(array &$converted, array &$data): bool { $billingAddress = $this->getAddress($data['billingAddress']); + if (empty($billingAddress)) { - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $this->runId, - DefaultEntities::ORDER, - $this->oldIdentifier, - 'billingAddress' - )); + $this->loggingService->addLogEntry( + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(OrderDefinition::ENTITY_NAME) + ->withFieldName('billingAddressId') + ->withFieldSourcePath('billingAddress') + ->withSourceData($data) + ->withConvertedData($converted) + ->build(EmptyNecessaryFieldRunLog::class) + ); return false; } diff --git a/src/Profile/Magento/Converter/ProductConverter.php b/src/Profile/Magento/Converter/ProductConverter.php index fd7e1a05..5ccfcc58 100644 --- a/src/Profile/Magento/Converter/ProductConverter.php +++ b/src/Profile/Magento/Converter/ProductConverter.php @@ -8,6 +8,7 @@ namespace Swag\MigrationMagento\Profile\Magento\Converter; 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; @@ -20,6 +21,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\Log\UnknownEntityLog; use SwagMigrationAssistant\Migration\Logging\LoggingServiceInterface; @@ -97,11 +99,7 @@ public function convert(array $data, Context $context, MigrationContextInterface unset($data['entity_id']); $converted = []; - $connection = $migrationContext->getConnection(); - $this->connectionId = ''; - if ($connection !== null) { - $this->connectionId = $connection->getId(); - } + $this->connectionId = $migrationContext->getConnection()->getId(); /* * Set manufacturer @@ -116,12 +114,12 @@ public function convert(array $data, Context $context, MigrationContextInterface */ if (!isset($data['tax_class_id'])) { $this->loggingService->addLogEntry( - new EmptyNecessaryFieldRunLog( - $this->runUuid, - DefaultEntities::PRODUCT, - $this->oldIdentifier, - 'tax class' - ) + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(ProductDefinition::ENTITY_NAME) + ->withFieldSourcePath('tax_class_id') + ->withSourceData($data) + ->withConvertedData($converted) + ->build(EmptyNecessaryFieldRunLog::class) ); return new ConvertStruct(null, $this->originalData); @@ -132,13 +130,13 @@ public function convert(array $data, Context $context, MigrationContextInterface */ if (!$this->setTax($data['tax_class_id'], $converted)) { $this->loggingService->addLogEntry( - new UnknownEntityLog( - $this->runUuid, - DefaultEntities::TAX, - $data['tax_class_id'], - DefaultEntities::PRODUCT, - $this->oldIdentifier - ) + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(ProductDefinition::ENTITY_NAME) + ->withFieldName('taxId') + ->withFieldSourcePath('tax_class_id') + ->withSourceData($data) + ->withConvertedData($converted) + ->build(UnknownEntityLog::class) ); return new ConvertStruct(null, $this->originalData); @@ -147,12 +145,13 @@ public function convert(array $data, Context $context, MigrationContextInterface if (!isset($data['price'])) { $this->loggingService->addLogEntry( - new EmptyNecessaryFieldRunLog( - $this->runUuid, - DefaultEntities::PRODUCT, - $this->oldIdentifier, - 'price' - ) + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(ProductDefinition::ENTITY_NAME) + ->withFieldName('price') + ->withFieldSourcePath('price') + ->withSourceData($data) + ->withConvertedData($converted) + ->build(EmptyNecessaryFieldRunLog::class) ); return new ConvertStruct(null, $this->originalData); @@ -162,12 +161,15 @@ public function convert(array $data, Context $context, MigrationContextInterface $converted['price'] = $this->getPrice($data, $converted); if (empty($converted['price'])) { - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $this->runUuid, - DefaultEntities::PRODUCT, - $this->oldIdentifier, - 'currency' - )); + $this->loggingService->addLogEntry( + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(ProductDefinition::ENTITY_NAME) + ->withFieldName('price') + ->withFieldSourcePath('price') + ->withSourceData($data) + ->withConvertedData($converted) + ->build(EmptyNecessaryFieldRunLog::class) + ); return new ConvertStruct(null, $this->originalData); } diff --git a/src/Profile/Magento/Converter/ProductMultiSelectPropertyRelationConverter.php b/src/Profile/Magento/Converter/ProductMultiSelectPropertyRelationConverter.php index f00385f2..152c4830 100644 --- a/src/Profile/Magento/Converter/ProductMultiSelectPropertyRelationConverter.php +++ b/src/Profile/Magento/Converter/ProductMultiSelectPropertyRelationConverter.php @@ -24,12 +24,7 @@ public function getSourceIdentifier(array $data): string public function convert(array $data, Context $context, MigrationContextInterface $migrationContext): ConvertStruct { $this->generateChecksum($data); - - $connection = $migrationContext->getConnection(); - $connectionId = ''; - if ($connection !== null) { - $connectionId = $connection->getId(); - } + $connectionId = $migrationContext->getConnection()->getId(); $productMapping = $this->mappingService->getMapping( $connectionId, diff --git a/src/Profile/Magento/Converter/ProductOptionRelationConverter.php b/src/Profile/Magento/Converter/ProductOptionRelationConverter.php index 3e039ba2..357bf27a 100644 --- a/src/Profile/Magento/Converter/ProductOptionRelationConverter.php +++ b/src/Profile/Magento/Converter/ProductOptionRelationConverter.php @@ -25,11 +25,7 @@ public function convert(array $data, Context $context, MigrationContextInterface { $this->generateChecksum($data); - $connection = $migrationContext->getConnection(); - $connectionId = ''; - if ($connection !== null) { - $connectionId = $connection->getId(); - } + $connectionId = $migrationContext->getConnection()->getId(); $productMapping = $this->mappingService->getMapping( $connectionId, diff --git a/src/Profile/Magento/Converter/ProductPropertyRelationConverter.php b/src/Profile/Magento/Converter/ProductPropertyRelationConverter.php index e3240bba..c13b3dd7 100644 --- a/src/Profile/Magento/Converter/ProductPropertyRelationConverter.php +++ b/src/Profile/Magento/Converter/ProductPropertyRelationConverter.php @@ -24,12 +24,7 @@ public function getSourceIdentifier(array $data): string public function convert(array $data, Context $context, MigrationContextInterface $migrationContext): ConvertStruct { $this->generateChecksum($data); - - $connection = $migrationContext->getConnection(); - $connectionId = ''; - if ($connection !== null) { - $connectionId = $connection->getId(); - } + $connectionId = $migrationContext->getConnection()->getId(); $productMapping = $this->mappingService->getMapping( $connectionId, diff --git a/src/Profile/Magento/Converter/ProductReviewConverter.php b/src/Profile/Magento/Converter/ProductReviewConverter.php index df810f47..a448f6ae 100644 --- a/src/Profile/Magento/Converter/ProductReviewConverter.php +++ b/src/Profile/Magento/Converter/ProductReviewConverter.php @@ -7,12 +7,14 @@ namespace Swag\MigrationMagento\Profile\Magento\Converter; +use Shopware\Core\Content\Product\Aggregate\ProductReview\ProductReviewDefinition; use Shopware\Core\Framework\Context; use Shopware\Core\Framework\Log\Package; use Swag\MigrationMagento\Profile\Magento\DataSelection\DefaultEntities as MagentoDefaultEntities; use SwagMigrationAssistant\Migration\Converter\ConvertStruct; use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; use SwagMigrationAssistant\Migration\Logging\Log\AssociationRequiredMissingLog; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; use SwagMigrationAssistant\Migration\MigrationContextInterface; #[Package('fundamentals@after-sales')] @@ -34,11 +36,7 @@ public function convert(array $data, Context $context, MigrationContextInterface $this->oldIdentifier = $data['review_id']; unset($data['review_id']); - $connection = $migrationContext->getConnection(); - $this->connectionId = ''; - if ($connection !== null) { - $this->connectionId = $connection->getId(); - } + $this->connectionId = $migrationContext->getConnection()->getId(); $converted = []; $this->mainMapping = $this->mappingService->getOrCreateMapping( @@ -59,16 +57,18 @@ public function convert(array $data, Context $context, MigrationContextInterface if ($mapping === null) { $this->loggingService->addLogEntry( - new AssociationRequiredMissingLog( - $migrationContext->getRunUuid(), - DefaultEntities::PRODUCT, - $data['productId'], - DefaultEntities::PRODUCT_REVIEW - ) + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(ProductReviewDefinition::ENTITY_NAME) + ->withFieldName('productId') + ->withFieldSourcePath('productId') + ->withSourceData($data) + ->withConvertedData($converted) + ->build(AssociationRequiredMissingLog::class) ); return new ConvertStruct(null, $this->originalData); } + $converted['productId'] = $mapping['entityUuid']; $this->mappingIds[] = $mapping['id']; unset($data['productId']); @@ -97,16 +97,18 @@ public function convert(array $data, Context $context, MigrationContextInterface if ($mapping === null) { $this->loggingService->addLogEntry( - new AssociationRequiredMissingLog( - $migrationContext->getRunUuid(), - DefaultEntities::SALES_CHANNEL, - $data['store_id'], - DefaultEntities::PRODUCT_REVIEW - ) + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(ProductReviewDefinition::ENTITY_NAME) + ->withFieldName('salesChannelId') + ->withFieldSourcePath('store_id') + ->withSourceData($data) + ->withConvertedData($converted) + ->build(AssociationRequiredMissingLog::class) ); return new ConvertStruct(null, $this->originalData); } + $converted['salesChannelId'] = $mapping['entityUuid']; $this->mappingIds[] = $mapping['id']; @@ -119,12 +121,13 @@ public function convert(array $data, Context $context, MigrationContextInterface if ($languageMapping === null) { $this->loggingService->addLogEntry( - new AssociationRequiredMissingLog( - $migrationContext->getRunUuid(), - MagentoDefaultEntities::STORE_LANGUAGE, - $data['store_id'], - DefaultEntities::PRODUCT_REVIEW - ) + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(ProductReviewDefinition::ENTITY_NAME) + ->withFieldName('languageId') + ->withFieldSourcePath('store_id') + ->withSourceData($data) + ->withConvertedData($converted) + ->build(AssociationRequiredMissingLog::class) ); return new ConvertStruct(null, $this->originalData); diff --git a/src/Profile/Magento/Converter/PropertyGroupConverter.php b/src/Profile/Magento/Converter/PropertyGroupConverter.php index 81dd1ebd..7ee28f32 100644 --- a/src/Profile/Magento/Converter/PropertyGroupConverter.php +++ b/src/Profile/Magento/Converter/PropertyGroupConverter.php @@ -7,12 +7,14 @@ namespace Swag\MigrationMagento\Profile\Magento\Converter; +use Shopware\Core\Content\Property\PropertyGroupDefinition; use Shopware\Core\Framework\Context; use Shopware\Core\Framework\Log\Package; use Shopware\Core\System\Language\LanguageEntity; use Swag\MigrationMagento\Migration\Mapping\MagentoMappingServiceInterface; 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\LanguageLookup; @@ -54,19 +56,17 @@ public function convert(array $data, Context $context, MigrationContextInterface $this->runId = $migrationContext->getRunUuid(); $this->oldIdentifier = $data['id']; $defaultLanguage = $this->languageLookup->getLanguageEntity($this->context); - $connection = $migrationContext->getConnection(); - $this->connectionId = ''; - if ($connection !== null) { - $this->connectionId = $connection->getId(); - } + $this->connectionId = $migrationContext->getConnection()->getId(); if (!isset($data['name'])) { - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $this->runId, - DefaultEntities::PROPERTY_GROUP, - $this->oldIdentifier, - 'group name' - )); + $this->loggingService->addLogEntry( + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(PropertyGroupDefinition::ENTITY_NAME) + ->withFieldName('name') + ->withFieldSourcePath('name') + ->withSourceData($data) + ->build(EmptyNecessaryFieldRunLog::class) + ); return new ConvertStruct(null, $this->originalData); } @@ -85,12 +85,15 @@ public function convert(array $data, Context $context, MigrationContextInterface ]; if (!isset($data['options'])) { - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $this->runId, - DefaultEntities::PROPERTY_GROUP, - $this->oldIdentifier, - 'options' - )); + $this->loggingService->addLogEntry( + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(PropertyGroupDefinition::ENTITY_NAME) + ->withFieldName('options') + ->withFieldSourcePath('options') + ->withSourceData($data) + ->withConvertedData($converted) + ->build(EmptyNecessaryFieldRunLog::class) + ); return new ConvertStruct(null, $this->originalData); } diff --git a/src/Profile/Magento/Converter/SalesChannelConverter.php b/src/Profile/Magento/Converter/SalesChannelConverter.php index 750241ef..2d970106 100644 --- a/src/Profile/Magento/Converter/SalesChannelConverter.php +++ b/src/Profile/Magento/Converter/SalesChannelConverter.php @@ -11,6 +11,7 @@ use Shopware\Core\Framework\Api\Util\AccessKeyHelper; use Shopware\Core\Framework\Context; use Shopware\Core\Framework\Log\Package; +use Shopware\Core\System\SalesChannel\SalesChannelDefinition; use Swag\MigrationMagento\Migration\Mapping\MagentoMappingServiceInterface; use Swag\MigrationMagento\Profile\Magento\DataSelection\DefaultEntities as MagentoDefaultEntities; use Swag\MigrationMagento\Profile\Magento\Premapping\PaymentMethodReader; @@ -18,6 +19,7 @@ use SwagMigrationAssistant\Migration\Converter\ConvertStruct; use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; use SwagMigrationAssistant\Migration\Logging\Log\AssociationRequiredMissingLog; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; use SwagMigrationAssistant\Migration\Logging\Log\EmptyNecessaryFieldRunLog; use SwagMigrationAssistant\Migration\Logging\Log\FieldReassignedRunLog; use SwagMigrationAssistant\Migration\Logging\LoggingServiceInterface; @@ -72,14 +74,18 @@ public function getSourceIdentifier(array $data): string public function convert(array $data, Context $context, MigrationContextInterface $migrationContext): ConvertStruct { + $this->migrationContext = $migrationContext; $fields = $this->checkForEmptyRequiredDataFields($data, self::$requiredDataFieldKeys); + if (!empty($fields)) { - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $migrationContext->getRunUuid(), - DefaultEntities::SALES_CHANNEL, - $data['group_id'], - \implode(',', $fields) - )); + $this->loggingService->addLogForEach( + $fields, + fn (string $key) => SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(SalesChannelDefinition::ENTITY_NAME) + ->withFieldSourcePath($key) + ->withSourceData($data) + ->build(EmptyNecessaryFieldRunLog::class) + ); return new ConvertStruct(null, $data); } @@ -93,11 +99,7 @@ public function convert(array $data, Context $context, MigrationContextInterface $this->runId = $migrationContext->getRunUuid(); $this->oldIdentifier = $data['group_id']; $converted = []; - $connection = $migrationContext->getConnection(); - $this->connectionId = ''; - if ($connection !== null) { - $this->connectionId = $connection->getId(); - } + $this->connectionId = $migrationContext->getConnection()->getId(); $defaultCustomerGroupId = $this->mappingService->getValue( $this->connectionId, @@ -105,6 +107,7 @@ public function convert(array $data, Context $context, MigrationContextInterface 'default_customer_group', $context ); + if ($defaultCustomerGroupId !== null) { $mapping = $this->mappingService->getMapping( $this->connectionId, @@ -119,12 +122,13 @@ public function convert(array $data, Context $context, MigrationContextInterface if (!isset($converted['customerGroupId'])) { $this->loggingService->addLogEntry( - new AssociationRequiredMissingLog( - $this->runId, - DefaultEntities::CUSTOMER_GROUP, - 'default_customer_group', - DefaultEntities::SALES_CHANNEL - ) + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(SalesChannelDefinition::ENTITY_NAME) + ->withFieldName('customerGroupId') + ->withFieldSourcePath('group_id') + ->withSourceData($data) + ->withConvertedData($converted) + ->build(AssociationRequiredMissingLog::class) ); return new ConvertStruct(null, $this->originalData); @@ -176,29 +180,32 @@ public function convert(array $data, Context $context, MigrationContextInterface * Set main language and allowed languages */ $languageUuid = $this->languageLookup->get($data['defaultLocale'], $context); + if ($languageUuid === null) { $defaultLanguage = $this->languageLookup->getLanguageEntity($context); + if ($defaultLanguage === null) { $this->loggingService->addLogEntry( - new AssociationRequiredMissingLog( - $this->runId, - DefaultEntities::LANGUAGE, - $data['defaultLocale'], - DefaultEntities::SALES_CHANNEL - ) + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(SalesChannelDefinition::ENTITY_NAME) + ->withFieldName('languageId') + ->withFieldSourcePath('defaultLocale') + ->withSourceData($data) + ->withConvertedData($converted) + ->build(AssociationRequiredMissingLog::class) ); return new ConvertStruct(null, $this->originalData); } $this->loggingService->addLogEntry( - new FieldReassignedRunLog( - $this->runId, - DefaultEntities::SALES_CHANNEL, - $this->oldIdentifier, - 'defaultLocale', - 'system default language' - ) + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(SalesChannelDefinition::ENTITY_NAME) + ->withFieldName('languageId') + ->withFieldSourcePath('defaultLocale') + ->withSourceData($data) + ->withConvertedData($converted) + ->build(FieldReassignedRunLog::class) ); $languageUuid = $defaultLanguage->getId(); @@ -233,19 +240,21 @@ public function convert(array $data, Context $context, MigrationContextInterface * Set main currency and allowed currencies */ $currencyUuid = $this->currencyLookup->get($data['defaultCurrency'], $context); + if ($currencyUuid === null) { $this->loggingService->addLogEntry( - new FieldReassignedRunLog( - $this->runId, - DefaultEntities::SALES_CHANNEL, - $this->oldIdentifier, - 'defaultCurrency', - 'system default currency' - ) + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(SalesChannelDefinition::ENTITY_NAME) + ->withFieldName('currencyId') + ->withFieldSourcePath('defaultCurrency') + ->withSourceData($data) + ->withConvertedData($converted) + ->build(FieldReassignedRunLog::class) ); $currencyUuid = Defaults::CURRENCY; } + $converted['currencyId'] = $currencyUuid; $converted['currencies'] = $this->getSalesChannelCurrencies($currencyUuid, $data, $context); unset($data['currencies'], $data['defaultCurrency']); @@ -255,6 +264,7 @@ public function convert(array $data, Context $context, MigrationContextInterface */ $mainCategory = $data['root_category_id']; $categoryMapping = null; + if ($mainCategory !== null) { $categoryMapping = $this->mappingService->getMapping( $this->connectionId, @@ -266,12 +276,13 @@ public function convert(array $data, Context $context, MigrationContextInterface if ($categoryMapping === null) { $this->loggingService->addLogEntry( - new AssociationRequiredMissingLog( - $this->runId, - DefaultEntities::CATEGORY, - $mainCategory ?? '', - DefaultEntities::SALES_CHANNEL - ) + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(SalesChannelDefinition::ENTITY_NAME) + ->withFieldName('navigationCategoryId') + ->withFieldSourcePath('root_category_id') + ->withSourceData($data) + ->withConvertedData($converted) + ->build(AssociationRequiredMissingLog::class) ); return new ConvertStruct(null, $this->originalData); @@ -285,18 +296,21 @@ public function convert(array $data, Context $context, MigrationContextInterface * Set main country and allowed countries */ $countryUuid = $this->getCountryUuid($data['defaultCountry'], $context); + if ($countryUuid === null) { $this->loggingService->addLogEntry( - new AssociationRequiredMissingLog( - $this->runId, - DefaultEntities::COUNTRY, - $data['defaultCountry'], - DefaultEntities::SALES_CHANNEL - ) + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(SalesChannelDefinition::ENTITY_NAME) + ->withFieldName('countryId') + ->withFieldSourcePath('defaultCountry') + ->withSourceData($data) + ->withConvertedData($converted) + ->build(AssociationRequiredMissingLog::class) ); return new ConvertStruct(null, $this->originalData); } + $converted['countryId'] = $countryUuid; $converted['countries'] = $this->getSalesChannelCountries($countryUuid, $data, $context); unset($data['countries'], $data['defaultCountry']); @@ -314,12 +328,15 @@ public function convert(array $data, Context $context, MigrationContextInterface ); if (empty($defaultPaymentMethod)) { - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $this->runId, - DefaultEntities::SALES_CHANNEL, - $this->oldIdentifier, - 'payment methods' - )); + $this->loggingService->addLogEntry( + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(SalesChannelDefinition::ENTITY_NAME) + ->withFieldName('paymentMethods') + ->withFieldSourcePath('default_payment_method') + ->withSourceData($data) + ->withConvertedData($converted) + ->build(EmptyNecessaryFieldRunLog::class) + ); return new ConvertStruct(null, $this->originalData); } @@ -333,16 +350,21 @@ public function convert(array $data, Context $context, MigrationContextInterface * Set main shipping method and allowed shipping methods */ $converted['shippingMethods'] = $this->getShippingMethods($data, $context); + if (empty($converted['shippingMethods'])) { - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $this->runId, - DefaultEntities::SALES_CHANNEL, - $this->oldIdentifier, - 'shipping methods' - )); + $this->loggingService->addLogEntry( + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(SalesChannelDefinition::ENTITY_NAME) + ->withFieldName('shippingMethodId') + ->withFieldSourcePath('default_shipping_method') + ->withSourceData($data) + ->withConvertedData($converted) + ->build(EmptyNecessaryFieldRunLog::class) + ); return new ConvertStruct(null, $this->originalData); } + $converted['shippingMethodId'] = $converted['shippingMethods'][0]['id']; unset($data['carriers']); @@ -454,12 +476,14 @@ protected function getPaymentMethods(array $data, Context $context): array ); if ($mapping === null) { - $this->loggingService->addLogEntry(new AssociationRequiredMissingLog( - $this->runId, - PaymentMethodReader::getMappingName(), - $payment['payment_id'], - DefaultEntities::SALES_CHANNEL - )); + $this->loggingService->addLogEntry( + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(SalesChannelDefinition::ENTITY_NAME) + ->withFieldName('paymentsMethodId') + ->withFieldSourcePath('payments.payment_id') + ->withSourceData($data) + ->build(EmptyNecessaryFieldRunLog::class) + ); continue; } @@ -502,12 +526,14 @@ protected function getShippingMethods(array $data, Context $context): array ); if ($mapping === null) { - $this->loggingService->addLogEntry(new AssociationRequiredMissingLog( - $this->runId, - ShippingMethodReader::getMappingName(), - $payment['carrier_id'], - DefaultEntities::SALES_CHANNEL - )); + $this->loggingService->addLogEntry( + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(SalesChannelDefinition::ENTITY_NAME) + ->withFieldName('shippingMethodsId') + ->withFieldSourcePath('carriers.carrier_id') + ->withSourceData($data) + ->build(AssociationRequiredMissingLog::class) + ); continue; } diff --git a/src/Profile/Magento/Converter/SeoUrlConverter.php b/src/Profile/Magento/Converter/SeoUrlConverter.php index f3158915..cd1ab5db 100644 --- a/src/Profile/Magento/Converter/SeoUrlConverter.php +++ b/src/Profile/Magento/Converter/SeoUrlConverter.php @@ -7,6 +7,7 @@ namespace Swag\MigrationMagento\Profile\Magento\Converter; +use Shopware\Core\Content\Seo\SeoUrl\SeoUrlDefinition; use Shopware\Core\Framework\Context; use Shopware\Core\Framework\Log\Package; use Shopware\Core\Framework\Util\Hasher; @@ -14,6 +15,7 @@ use SwagMigrationAssistant\Migration\Converter\ConvertStruct; use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; use SwagMigrationAssistant\Migration\Logging\Log\AssociationRequiredMissingLog; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; use SwagMigrationAssistant\Migration\Logging\Log\EmptyNecessaryFieldRunLog; use SwagMigrationAssistant\Migration\MigrationContextInterface; @@ -34,12 +36,7 @@ public function convert(array $data, Context $context, MigrationContextInterface { $this->generateChecksum($data); $this->originalData = $data; - - $connection = $migrationContext->getConnection(); - $this->connectionId = ''; - if ($connection !== null) { - $this->connectionId = $connection->getId(); - } + $this->connectionId = $migrationContext->getConnection()->getId(); $converted = []; $this->mainMapping = $this->mappingService->getOrCreateMapping( @@ -60,12 +57,13 @@ public function convert(array $data, Context $context, MigrationContextInterface if ($mapping === null) { $this->loggingService->addLogEntry( - new AssociationRequiredMissingLog( - $migrationContext->getRunUuid(), - DefaultEntities::SALES_CHANNEL, - $data['store_id'], - DefaultEntities::SEO_URL - ) + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(SeoUrlDefinition::ENTITY_NAME) + ->withFieldName('salesChannelId') + ->withFieldSourcePath('store_id') + ->withSourceData($data) + ->withConvertedData($converted) + ->build(AssociationRequiredMissingLog::class) ); return new ConvertStruct(null, $this->originalData); @@ -82,12 +80,13 @@ public function convert(array $data, Context $context, MigrationContextInterface if ($languageMapping === null) { $this->loggingService->addLogEntry( - new AssociationRequiredMissingLog( - $migrationContext->getRunUuid(), - MagentoDefaultEntities::STORE_LANGUAGE, - $data['store_id'], - DefaultEntities::SEO_URL - ) + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(SeoUrlDefinition::ENTITY_NAME) + ->withFieldName('languageId') + ->withFieldSourcePath('store_id') + ->withSourceData($data) + ->withConvertedData($converted) + ->build(AssociationRequiredMissingLog::class) ); return new ConvertStruct(null, $this->originalData); @@ -112,12 +111,13 @@ public function convert(array $data, Context $context, MigrationContextInterface if ($mapping === null) { $this->loggingService->addLogEntry( - new AssociationRequiredMissingLog( - $migrationContext->getRunUuid(), - DefaultEntities::PRODUCT, - $data['product_id'], - DefaultEntities::SEO_URL - ) + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(SeoUrlDefinition::ENTITY_NAME) + ->withFieldName('foreignKey') + ->withFieldSourcePath('product_id') + ->withSourceData($data) + ->withConvertedData($converted) + ->build(AssociationRequiredMissingLog::class) ); return new ConvertStruct(null, $this->originalData); @@ -136,12 +136,13 @@ public function convert(array $data, Context $context, MigrationContextInterface if ($mapping === null) { $this->loggingService->addLogEntry( - new AssociationRequiredMissingLog( - $migrationContext->getRunUuid(), - DefaultEntities::CATEGORY, - $data['category_id'], - DefaultEntities::SEO_URL - ) + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(SeoUrlDefinition::ENTITY_NAME) + ->withFieldName('foreignKey') + ->withFieldSourcePath('category_id') + ->withSourceData($data) + ->withConvertedData($converted) + ->build(AssociationRequiredMissingLog::class) ); return new ConvertStruct(null, $this->originalData); @@ -154,12 +155,12 @@ public function convert(array $data, Context $context, MigrationContextInterface $this->mappingIds[] = $mapping['id']; } else { $this->loggingService->addLogEntry( - new EmptyNecessaryFieldRunLog( - $migrationContext->getRunUuid(), - DefaultEntities::SEO_URL, - $this->originalData['url_rewrite_id'], - 'category_id, product_id' - ) + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(SeoUrlDefinition::ENTITY_NAME) + ->withFieldName('foreignKey') + ->withSourceData($data) + ->withConvertedData($converted) + ->build(EmptyNecessaryFieldRunLog::class) ); return new ConvertStruct(null, $this->originalData); diff --git a/src/Profile/Magento/Gateway/Connection/ConnectionFactory.php b/src/Profile/Magento/Gateway/Connection/ConnectionFactory.php index 2a1005a3..a9217937 100644 --- a/src/Profile/Magento/Gateway/Connection/ConnectionFactory.php +++ b/src/Profile/Magento/Gateway/Connection/ConnectionFactory.php @@ -20,13 +20,7 @@ class ConnectionFactory implements ConnectionFactoryInterface { public function createDatabaseConnection(MigrationContextInterface $migrationContext): ?Connection { - $connection = $migrationContext->getConnection(); - - if ($connection === null) { - return null; - } - - $credentials = $connection->getCredentialFields(); + $credentials = $migrationContext->getConnection()->getCredentialFields(); if ($credentials === null) { return null; diff --git a/src/Profile/Magento/Gateway/Local/Reader/AbstractReader.php b/src/Profile/Magento/Gateway/Local/Reader/AbstractReader.php index a94e600a..d866e4cd 100644 --- a/src/Profile/Magento/Gateway/Local/Reader/AbstractReader.php +++ b/src/Profile/Magento/Gateway/Local/Reader/AbstractReader.php @@ -52,18 +52,15 @@ protected function setConnection(MigrationContextInterface $migrationContext): v return; } - $connection = $migrationContext->getConnection(); - if ($connection === null) { - return; - } - $dbConnection = $this->connectionFactory->createDatabaseConnection($migrationContext); + if ($dbConnection === null) { return; } $this->connection = $dbConnection; - $credentials = $connection->getCredentialFields(); + $credentials = $migrationContext->getConnection()->getCredentialFields(); + if (isset($credentials['tablePrefix'])) { $this->tablePrefix = (string) $credentials['tablePrefix']; } diff --git a/src/Profile/Magento/Gateway/Local/Reader/EnvironmentReader.php b/src/Profile/Magento/Gateway/Local/Reader/EnvironmentReader.php index 47fa680c..7cd3b4a0 100644 --- a/src/Profile/Magento/Gateway/Local/Reader/EnvironmentReader.php +++ b/src/Profile/Magento/Gateway/Local/Reader/EnvironmentReader.php @@ -49,18 +49,15 @@ public function read(MigrationContextInterface $migrationContext, array $params protected function setConnection(MigrationContextInterface $migrationContext): void { - $connection = $migrationContext->getConnection(); - if ($connection === null) { - return; - } - $dbConnection = $this->connectionFactory->createDatabaseConnection($migrationContext); + if ($dbConnection === null) { return; } $this->connection = $dbConnection; - $credentials = $connection->getCredentialFields(); + $credentials = $migrationContext->getConnection()->getCredentialFields(); + if (isset($credentials['tablePrefix'])) { $this->tablePrefix = (string) $credentials['tablePrefix']; } diff --git a/src/Profile/Magento/Gateway/Local/Reader/LocalTableReader.php b/src/Profile/Magento/Gateway/Local/Reader/LocalTableReader.php index 5e786a51..b489ef53 100644 --- a/src/Profile/Magento/Gateway/Local/Reader/LocalTableReader.php +++ b/src/Profile/Magento/Gateway/Local/Reader/LocalTableReader.php @@ -28,6 +28,7 @@ public function __construct(ConnectionFactoryInterface $connectionFactory) public function read(MigrationContextInterface $migrationContext, string $tableName, array $filter = []): array { $connection = $this->connectionFactory->createDatabaseConnection($migrationContext); + if ($connection === null) { return []; } diff --git a/src/Profile/Magento/Gateway/Local/Reader/NotAssociatedMediaReader.php b/src/Profile/Magento/Gateway/Local/Reader/NotAssociatedMediaReader.php index e143fe5e..0221bb23 100644 --- a/src/Profile/Magento/Gateway/Local/Reader/NotAssociatedMediaReader.php +++ b/src/Profile/Magento/Gateway/Local/Reader/NotAssociatedMediaReader.php @@ -52,15 +52,12 @@ protected function dirToArray(string $dir, array &$result): void private function getInstallationRoot(MigrationContextInterface $migrationContext): string { - $connection = $migrationContext->getConnection(); - if ($connection === null) { - return ''; - } + $credentials = $migrationContext->getConnection()->getCredentialFields(); - $credentials = $connection->getCredentialFields(); if (!isset($credentials['installationRoot']) || $credentials['installationRoot'] === '') { return ''; } + $installRoot = (string) $credentials['installationRoot']; $installRoot = \ltrim($installRoot, '/'); $installRoot = \rtrim($installRoot, '/'); diff --git a/src/Profile/Magento/Gateway/Local/Reader/OrderReader.php b/src/Profile/Magento/Gateway/Local/Reader/OrderReader.php index b768bd42..71b05d5f 100644 --- a/src/Profile/Magento/Gateway/Local/Reader/OrderReader.php +++ b/src/Profile/Magento/Gateway/Local/Reader/OrderReader.php @@ -167,6 +167,7 @@ protected function fetchDetails(array $ids): array protected function fetchShipments(array $ids): array { $connection = $this->connection; + if ($connection === null) { throw MigrationException::databaseConnectionError(); } diff --git a/src/Profile/Magento/Media/LocalMediaProcessor.php b/src/Profile/Magento/Media/LocalMediaProcessor.php index 883aab40..48366832 100644 --- a/src/Profile/Magento/Media/LocalMediaProcessor.php +++ b/src/Profile/Magento/Media/LocalMediaProcessor.php @@ -15,6 +15,7 @@ use Shopware\Core\Content\Media\File\FileSaver; use Shopware\Core\Content\Media\File\MediaFile; use Shopware\Core\Content\Media\MediaCollection; +use Shopware\Core\Content\Media\MediaDefinition; use Shopware\Core\Content\Media\MediaException; use Shopware\Core\Framework\Context; use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; @@ -25,6 +26,7 @@ use Swag\MigrationMagento\Profile\Magento\DataSelection\DataSet\MediaDataSet; use Swag\MigrationMagento\Profile\Magento19\Magento19Profile; use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; use SwagMigrationAssistant\Migration\Logging\Log\CannotGetFileRunLog; use SwagMigrationAssistant\Migration\Logging\Log\ExceptionRunLog; use SwagMigrationAssistant\Migration\Logging\Log\MimeTypeErrorLog; @@ -98,11 +100,15 @@ public function process( $shopUrl = $this->getShopUrl($migrationContext); if ($shopUrl === '') { - $this->loggingService->addLogEntry(new ExceptionRunLog( - $runId, - DefaultEntities::MEDIA, - MigrationMagentoException::mediaPathNotReachable($installationRoot), - )); + $exception = MigrationMagentoException::mediaPathNotReachable($installationRoot); + + $this->loggingService->addLogEntry( + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(MediaDefinition::ENTITY_NAME) + ->withExceptionMessage($exception->getMessage()) + ->withExceptionTrace($exception->getTrace()) + ->build(ExceptionRunLog::class) + ); $this->loggingService->saveLogging($context); return $workload; @@ -175,15 +181,12 @@ protected function doNormalDownloadRequest(MediaProcessWorkloadStruct $workload, protected function getInstallationRoot(MigrationContextInterface $migrationContext): string { - $connection = $migrationContext->getConnection(); - if ($connection === null) { - return ''; - } + $credentials = $migrationContext->getConnection()->getCredentialFields(); - $credentials = $connection->getCredentialFields(); if (!isset($credentials['installationRoot']) || $credentials['installationRoot'] === '') { return ''; } + $installRoot = (string) $credentials['installationRoot']; $installRoot = \ltrim($installRoot, '/'); $installRoot = \rtrim($installRoot, '/'); @@ -239,14 +242,17 @@ private function copyMediaFiles( $fileExtension = \pathinfo($sourcePath, \PATHINFO_EXTENSION); $filePath = \tempnam(\sys_get_temp_dir(), 'SwagMigrationMagento-'); + if ($filePath === false) { $failureUuids[] = (string) $mediaId; $mappedWorkload[$mediaId]->setState(MediaProcessWorkloadStruct::ERROR_STATE); - $this->loggingService->addLogEntry(new TemporaryFileErrorLog( - $mappedWorkload[$mediaId]->getRunId(), - DefaultEntities::MEDIA, - $mediaId - )); + + $this->loggingService->addLogEntry( + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(MediaDefinition::ENTITY_NAME) + ->withSourceData($mediaFile) + ->build(TemporaryFileErrorLog::class) + ); continue; } @@ -272,23 +278,25 @@ private function copyMediaFiles( } catch (\Exception $e) { $failureUuids[] = $mediaId; $mappedWorkload[$mediaId]->setState(MediaProcessWorkloadStruct::ERROR_STATE); - $this->loggingService->addLogEntry(new ExceptionRunLog( - $mappedWorkload[$mediaId]->getRunId(), - DefaultEntities::MEDIA, - $e, - $mediaId - )); + $this->loggingService->addLogEntry( + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(MediaDefinition::ENTITY_NAME) + ->withSourceData($mediaFile) + ->withExceptionMessage($e->getMessage()) + ->withExceptionTrace($e->getTrace()) + ->build(ExceptionRunLog::class) + ); } \unlink($filePath); } else { $mappedWorkload[$mediaId]->setState(MediaProcessWorkloadStruct::ERROR_STATE); - $this->loggingService->addLogEntry(new CannotGetFileRunLog( - $mappedWorkload[$mediaId]->getRunId(), - DefaultEntities::MEDIA, - $mediaId, - $sourcePath - )); + $this->loggingService->addLogEntry( + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(MediaDefinition::ENTITY_NAME) + ->withSourceData($mediaFile) + ->build(CannotGetFileRunLog::class) + ); $failureUuids[] = $mediaId; } $processedMedia[] = $mediaId; @@ -317,11 +325,18 @@ private function persistFileToMedia( if ($mimeType === false) { $failedMedia[] = $mediaId; $mappedWorkload[$mediaId]->setState(MediaProcessWorkloadStruct::ERROR_STATE); - $this->loggingService->addLogEntry(new MimeTypeErrorLog( - $mappedWorkload[$mediaId]->getRunId(), - DefaultEntities::MEDIA, - $mediaId - )); + $this->loggingService->addLogEntry( + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(MediaDefinition::ENTITY_NAME) + ->withFieldName('mime_type') + ->withFieldSourcePath('file_path') + ->withSourceData([ + 'file_name' => $fileName, + 'file_path' => $filePath, + 'media' => $mappedWorkload[$mediaId], + ]) + ->build(MimeTypeErrorLog::class) + ); return; } @@ -347,12 +362,8 @@ private function persistFileToMedia( private function getShopUrl(MigrationContextInterface $migrationContext): string { - $connection = $migrationContext->getConnection(); - if ($connection === null) { - return ''; - } + $credentials = $migrationContext->getConnection()->getCredentialFields(); - $credentials = $connection->getCredentialFields(); if (!isset($credentials['shopUrl'])) { return ''; } @@ -407,12 +418,12 @@ function (MediaProcessWorkloadStruct $work) use ($uuid) { if ($mappedWorkload[$uuid]->getErrorCount() > ProcessMediaHandler::MEDIA_ERROR_THRESHOLD) { $failureUuids[] = $uuid; $mappedWorkload[$uuid]->setState(MediaProcessWorkloadStruct::ERROR_STATE); - $this->loggingService->addLogEntry(new CannotGetFileRunLog( - $mappedWorkload[$uuid]->getRunId(), - DefaultEntities::MEDIA, - $mappedWorkload[$uuid]->getMediaId(), - $mappedWorkload[$uuid]->getAdditionalData()['uri'] - )); + $this->loggingService->addLogEntry( + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(MediaDefinition::ENTITY_NAME) + ->withSourceData($media) + ->build(CannotGetFileRunLog::class) + ); } continue; @@ -425,11 +436,12 @@ function (MediaProcessWorkloadStruct $work) use ($uuid) { if ($filePath === false) { $failureUuids[] = $uuid; $mappedWorkload[$uuid]->setState(MediaProcessWorkloadStruct::ERROR_STATE); - $this->loggingService->addLogEntry(new TemporaryFileErrorLog( - $mappedWorkload[$uuid]->getRunId(), - DefaultEntities::MEDIA, - $uuid - )); + $this->loggingService->addLogEntry( + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(MediaDefinition::ENTITY_NAME) + ->withSourceData($media) + ->build(TemporaryFileErrorLog::class) + ); continue; } @@ -445,11 +457,13 @@ function (MediaProcessWorkloadStruct $work) use ($uuid) { if ($fileHandle === false) { $failureUuids[] = $uuid; $mappedWorkload[$uuid]->setState(MediaProcessWorkloadStruct::ERROR_STATE); - $this->loggingService->addLogEntry(new FileHandleErrorLog( - $mappedWorkload[$uuid]->getRunId(), - DefaultEntities::MEDIA, - $uuid - )); + + $this->loggingService->addLogEntry( + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(DefaultEntities::MEDIA) + ->withSourceData($media) + ->build(FileHandleErrorLog::class) + ); continue; } @@ -474,12 +488,14 @@ function (MediaProcessWorkloadStruct $work) use ($uuid) { } catch (\Exception $e) { $failureUuids[] = $uuid; $mappedWorkload[$uuid]->setState(MediaProcessWorkloadStruct::ERROR_STATE); - $this->loggingService->addLogEntry(new ExceptionRunLog( - $mappedWorkload[$uuid]->getRunId(), - DefaultEntities::MEDIA, - $e, - $uuid - )); + $this->loggingService->addLogEntry( + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(MediaDefinition::ENTITY_NAME) + ->withSourceData($media) + ->withExceptionMessage($e->getMessage()) + ->withExceptionTrace($e->getTrace()) + ->build(ExceptionRunLog::class) + ); } } diff --git a/src/Profile/Magento/Premapping/NewsletterRecipientStatusReader.php b/src/Profile/Magento/Premapping/NewsletterRecipientStatusReader.php index aa7b7c8e..62a4f3b6 100644 --- a/src/Profile/Magento/Premapping/NewsletterRecipientStatusReader.php +++ b/src/Profile/Magento/Premapping/NewsletterRecipientStatusReader.php @@ -47,7 +47,6 @@ public function getPremapping(Context $context, MigrationContextInterface $migra protected function getMapping(MigrationContextInterface $migrationContext): array { $mapping = []; - $connection = $migrationContext->getConnection(); $choices = [ '1' => 'Subscribed', '2' => 'Not active', @@ -56,11 +55,8 @@ protected function getMapping(MigrationContextInterface $migrationContext): arra 'default_newsletter_recipient_status' => 'Standard newsletter status', ]; - if ($connection === null) { - return $mapping; - } + $connectionPremapping = $migrationContext->getConnection()->getPremapping(); - $connectionPremapping = $connection->getPremapping(); if ($connectionPremapping === null) { foreach ($choices as $key => $choice) { $mapping[] = new PremappingEntityStruct((string) $key, $choice, ''); @@ -83,6 +79,7 @@ protected function getMapping(MigrationContextInterface $migrationContext): arra foreach ($choices as $key => $choice) { $mapping[] = new PremappingEntityStruct((string) $key, $choice, ''); } + \usort($mapping, function (PremappingEntityStruct $item1, PremappingEntityStruct $item2) { return \strcmp($item1->getDescription(), $item2->getDescription()); }); diff --git a/src/Profile/Magento19/Gateway/Local/Magento19LocalGateway.php b/src/Profile/Magento19/Gateway/Local/Magento19LocalGateway.php index e5231aa2..ca527007 100644 --- a/src/Profile/Magento19/Gateway/Local/Magento19LocalGateway.php +++ b/src/Profile/Magento19/Gateway/Local/Magento19LocalGateway.php @@ -22,6 +22,7 @@ use SwagMigrationAssistant\Migration\Gateway\Reader\EnvironmentReaderInterface; use SwagMigrationAssistant\Migration\Gateway\Reader\ReaderRegistryInterface; use SwagMigrationAssistant\Migration\MigrationContextInterface; +use SwagMigrationAssistant\Migration\Profile\ProfileInterface; use SwagMigrationAssistant\Migration\RequestStatusStruct; #[Package('fundamentals@after-sales')] @@ -71,9 +72,9 @@ public function getSnippetName(): string return 'swag-migration.wizard.pages.connectionCreate.gateways.magentoLocal'; } - public function supports(MigrationContextInterface $migrationContext): bool + public function supports(ProfileInterface $profile): bool { - return $migrationContext->getProfile() instanceof Magento19Profile; + return $profile instanceof Magento19Profile; } public function read(MigrationContextInterface $migrationContext): array @@ -275,12 +276,8 @@ public function readStores(MigrationContextInterface $migrationContext): array protected function getTablePrefixFromCredentials(MigrationContextInterface $migrationContext): string { $tablePrefix = ''; - $connection = $migrationContext->getConnection(); - if ($connection === null) { - return $tablePrefix; - } - $credentials = $connection->getCredentialFields(); + $credentials = $migrationContext->getConnection()->getCredentialFields(); if (isset($credentials['tablePrefix'])) { $tablePrefix = $credentials['tablePrefix']; } diff --git a/src/Profile/Magento2/Converter/Magento2CustomerConverter.php b/src/Profile/Magento2/Converter/Magento2CustomerConverter.php index bcf43616..7531a88a 100644 --- a/src/Profile/Magento2/Converter/Magento2CustomerConverter.php +++ b/src/Profile/Magento2/Converter/Magento2CustomerConverter.php @@ -7,12 +7,13 @@ namespace Swag\MigrationMagento\Profile\Magento2\Converter; +use Shopware\Core\Checkout\Customer\CustomerDefinition; use Shopware\Core\Framework\Log\Package; use Swag\MigrationMagento\Profile\Magento\Converter\CustomerConverter; use Swag\MigrationMagento\Profile\Magento2\PasswordEncoder\Magento2Argon2Id13Encoder; use Swag\MigrationMagento\Profile\Magento2\PasswordEncoder\Magento2Md5Encoder; use Swag\MigrationMagento\Profile\Magento2\PasswordEncoder\Magento2Sha256Encoder; -use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; use SwagMigrationAssistant\Migration\Logging\Log\ExceptionRunLog; #[Package('fundamentals@after-sales')] @@ -34,13 +35,18 @@ protected function setPassword(array &$data, array &$converted): bool $converted['legacyEncoder'] = Magento2Argon2Id13Encoder::NAME; if (!\defined('SODIUM_CRYPTO_PWHASH_ALG_ARGON2ID13') || !\extension_loaded('sodium')) { + $exception = new \Exception('Password algorithm is not available, please install and activate sodium php extension.'); + $this->loggingService->addLogEntry( - new ExceptionRunLog( - $this->runId, - DefaultEntities::CUSTOMER, - new \Exception('Password algorithm is not available, please install and activate sodium php extension.'), - $this->oldIdentifier - ) + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(CustomerDefinition::ENTITY_NAME) + ->withFieldName('password_hash') + ->withFieldSourcePath('password_hash') + ->withSourceData($data) + ->withConvertedData($converted) + ->withExceptionMessage($exception->getMessage()) + ->withExceptionTrace($exception->getTrace()) + ->build(ExceptionRunLog::class) ); return false; diff --git a/src/Profile/Magento2/Converter/Magento2OrderConverter.php b/src/Profile/Magento2/Converter/Magento2OrderConverter.php index e7811027..e863c7e6 100644 --- a/src/Profile/Magento2/Converter/Magento2OrderConverter.php +++ b/src/Profile/Magento2/Converter/Magento2OrderConverter.php @@ -7,12 +7,15 @@ namespace Swag\MigrationMagento\Profile\Magento2\Converter; +use Shopware\Core\Checkout\Customer\CustomerDefinition; +use Shopware\Core\Checkout\Order\Aggregate\OrderCustomer\OrderCustomerDefinition; use Shopware\Core\Framework\Log\Package; use Swag\MigrationMagento\Profile\Magento\Converter\OrderConverter; use Swag\MigrationMagento\Profile\Magento\DataSelection\DefaultEntities as MagentoDefaultEntities; use SwagMigrationAssistant\Exception\AssociationEntityRequiredMissingException; use SwagMigrationAssistant\Exception\MigrationException; use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; use SwagMigrationAssistant\Migration\Logging\Log\EmptyNecessaryFieldRunLog; #[Package('fundamentals@after-sales')] @@ -75,12 +78,16 @@ protected function convertOrderCustomer(array &$converted, array &$data): bool ); if ($mapping === null || !isset($mapping['entityUuid'])) { - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $this->runId, - DefaultEntities::ORDER, - $this->oldIdentifier, - 'salutation' - )); + $this->loggingService->addLogEntry( + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(OrderCustomerDefinition::ENTITY_NAME) + ->withFieldName('salutationId') + ->withFieldSourcePath('default_salutation') + ->withSourceData($data) + ->withConvertedData($converted) + ->withUsedMapping($mapping ?? []) + ->build(EmptyNecessaryFieldRunLog::class) + ); return false; } @@ -102,12 +109,15 @@ protected function convertOrderCustomer(array &$converted, array &$data): bool ); if ($customerGroupMapping === null) { - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $this->runId, - DefaultEntities::ORDER, - $this->oldIdentifier, - 'customer_group_id' - )); + $this->loggingService->addLogEntry( + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(CustomerDefinition::ENTITY_NAME) + ->withFieldName('customerGroupId') + ->withFieldSourcePath('orders.customer_group_id') + ->withSourceData($data) + ->withConvertedData($converted) + ->build(EmptyNecessaryFieldRunLog::class) + ); return false; } @@ -118,25 +128,33 @@ protected function convertOrderCustomer(array &$converted, array &$data): bool $data['orders']['store_id'], $this->context ); + if ($languageMapping === null) { - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $this->runId, - DefaultEntities::ORDER, - $this->oldIdentifier, - 'language' - )); + $this->loggingService->addLogEntry( + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(CustomerDefinition::ENTITY_NAME) + ->withFieldName('languageId') + ->withFieldSourcePath('order.store_id') + ->withSourceData($data) + ->withConvertedData($converted) + ->build(EmptyNecessaryFieldRunLog::class) + ); return false; } - $paymentMethodUuid = $this->getPaymentMethod($data); + $paymentMethodUuid = $this->getPaymentMethod($data, OrderCustomerDefinition::ENTITY_NAME); + if ($paymentMethodUuid === null) { - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $this->runId, - DefaultEntities::ORDER, - $this->oldIdentifier, - 'payment_method' - )); + $this->loggingService->addLogEntry( + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(CustomerDefinition::ENTITY_NAME) + ->withFieldName('defaultPaymentMethodId') + ->withFieldSourcePath('order.payment.method') + ->withSourceData($data) + ->withConvertedData($converted) + ->build(EmptyNecessaryFieldRunLog::class) + ); return false; } @@ -150,16 +168,21 @@ protected function convertOrderCustomer(array &$converted, array &$data): bool $converted['orderCustomer']['customer']['customerNumber'] = $this->numberRangeValueGenerator->getValue('customer', $this->context, null); $billingAddress = $this->getAddress($data['billingAddress'], DefaultEntities::CUSTOMER_ADDRESS); + if (empty($billingAddress)) { - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $this->runId, - DefaultEntities::ORDER, - $this->oldIdentifier, - 'billingAddress' - )); + $this->loggingService->addLogEntry( + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(CustomerDefinition::ENTITY_NAME) + ->withFieldName('defaultBillingAddressId') + ->withFieldSourcePath('billingAddress') + ->withSourceData($data) + ->withConvertedData($converted) + ->build(EmptyNecessaryFieldRunLog::class) + ); return false; } + $converted['orderCustomer']['customer']['addresses'][] = $billingAddress; $converted['orderCustomer']['customer']['defaultBillingAddressId'] = $billingAddress['id']; $shippingAddress = $this->getAddress($data['shippingAddress'], DefaultEntities::CUSTOMER_ADDRESS); diff --git a/src/Profile/Magento2/Converter/Magento2SalesChannelConverter.php b/src/Profile/Magento2/Converter/Magento2SalesChannelConverter.php index 23425b42..604b3af1 100644 --- a/src/Profile/Magento2/Converter/Magento2SalesChannelConverter.php +++ b/src/Profile/Magento2/Converter/Magento2SalesChannelConverter.php @@ -11,6 +11,7 @@ use Shopware\Core\Framework\Api\Util\AccessKeyHelper; use Shopware\Core\Framework\Context; use Shopware\Core\Framework\Log\Package; +use Shopware\Core\System\SalesChannel\SalesChannelDefinition; use Swag\MigrationMagento\Profile\Magento\Converter\SalesChannelConverter; use Swag\MigrationMagento\Profile\Magento\DataSelection\DefaultEntities as MagentoDefaultEntities; use Swag\MigrationMagento\Profile\Magento\Premapping\PaymentMethodReader; @@ -21,6 +22,7 @@ use SwagMigrationAssistant\Migration\Converter\ConvertStruct; use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; use SwagMigrationAssistant\Migration\Logging\Log\AssociationRequiredMissingLog; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; use SwagMigrationAssistant\Migration\Logging\Log\EmptyNecessaryFieldRunLog; use SwagMigrationAssistant\Migration\MigrationContextInterface; @@ -39,14 +41,18 @@ abstract class Magento2SalesChannelConverter extends SalesChannelConverter public function convert(array $data, Context $context, MigrationContextInterface $migrationContext): ConvertStruct { + $this->migrationContext = $migrationContext; $fields = $this->checkForEmptyRequiredDataFields($data, self::$requiredDataFieldKeys); + if (!empty($fields)) { - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $migrationContext->getRunUuid(), - DefaultEntities::SALES_CHANNEL, - $data['group_id'], - \implode(',', $fields) - )); + $this->loggingService->addLogForEach( + $fields, + fn (string $key) => SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(SalesChannelDefinition::ENTITY_NAME) + ->withFieldSourcePath($key) + ->withSourceData($data) + ->build(EmptyNecessaryFieldRunLog::class) + ); return new ConvertStruct(null, $data); } @@ -59,13 +65,9 @@ public function convert(array $data, Context $context, MigrationContextInterface $this->context = $context; $this->runId = $migrationContext->getRunUuid(); $this->oldIdentifier = $data['group_id']; + $this->connectionId = $migrationContext->getConnection()->getId(); - $connection = $migrationContext->getConnection(); $converted = []; - $this->connectionId = ''; - if ($connection !== null) { - $this->connectionId = $connection->getId(); - } $defaultCustomerGroupId = $this->mappingService->getValue( $this->connectionId, @@ -88,12 +90,13 @@ public function convert(array $data, Context $context, MigrationContextInterface if (!isset($converted['customerGroupId'])) { $this->loggingService->addLogEntry( - new AssociationRequiredMissingLog( - $this->runId, - DefaultEntities::CUSTOMER_GROUP, - 'default_customer_group', - DefaultEntities::SALES_CHANNEL - ) + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(SalesChannelDefinition::ENTITY_NAME) + ->withFieldName('customerGroupId') + ->withFieldSourcePath('default_customer_group') + ->withSourceData($data) + ->withConvertedData($converted) + ->build(AssociationRequiredMissingLog::class) ); return new ConvertStruct(null, $this->originalData); @@ -216,12 +219,14 @@ protected function setLanguageUuid(array &$data, array &$converted, Context $con if ($languageMapping === null || !isset($languageMapping['entityUuid'])) { $this->loggingService->addLogEntry( - new AssociationRequiredMissingLog( - $this->runId, - DefaultEntities::LANGUAGE, - 'default_locale', - DefaultEntities::SALES_CHANNEL - ) + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(SalesChannelDefinition::ENTITY_NAME) + ->withFieldName('languageId') + ->withFieldSourcePath('default_language') + ->withSourceData($data) + ->withConvertedData($converted) + ->withUsedMapping($languageMapping ?? []) + ->build(AssociationRequiredMissingLog::class) ); return null; @@ -276,12 +281,14 @@ protected function setCurrencyUuid(array &$data, array &$converted): ?string if ($currencyMapping === null || !isset($currencyMapping['entityUuid'])) { $this->loggingService->addLogEntry( - new AssociationRequiredMissingLog( - $this->runId, - DefaultEntities::CURRENCY, - 'default_currency', - DefaultEntities::SALES_CHANNEL - ) + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(SalesChannelDefinition::ENTITY_NAME) + ->withFieldName('currencyId') + ->withFieldSourcePath('default_currency') + ->withSourceData($data) + ->withConvertedData($converted) + ->withUsedMapping($currencyMapping ?? []) + ->build(AssociationRequiredMissingLog::class) ); return null; @@ -308,12 +315,13 @@ protected function setCategoryUuid(array &$data, array &$converted): ?string if ($categoryMapping === null) { $this->loggingService->addLogEntry( - new AssociationRequiredMissingLog( - $this->runId, - DefaultEntities::CATEGORY, - $data['root_category_id'], - DefaultEntities::SALES_CHANNEL - ) + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(SalesChannelDefinition::ENTITY_NAME) + ->withFieldName('navigationCategoryId') + ->withFieldSourcePath('root_category_id') + ->withSourceData($data) + ->withConvertedData($converted) + ->build(AssociationRequiredMissingLog::class) ); return null; @@ -357,12 +365,13 @@ protected function setCountryUuid(array &$data, array &$converted): ?string if ($countryMapping === null) { $this->loggingService->addLogEntry( - new AssociationRequiredMissingLog( - $this->runId, - DefaultEntities::COUNTRY, - 'default_country', - DefaultEntities::SALES_CHANNEL - ) + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(SalesChannelDefinition::ENTITY_NAME) + ->withFieldName('countryId') + ->withFieldSourcePath('default_country') + ->withSourceData($data) + ->withConvertedData($converted) + ->build(AssociationRequiredMissingLog::class) ); return null; @@ -390,12 +399,15 @@ protected function setPaymentMethodUuid(array &$data, array &$converted): ?strin ); if ($paymentMethodMapping === null) { - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $this->runId, - DefaultEntities::SALES_CHANNEL, - $this->oldIdentifier, - 'payment methods' - )); + $this->loggingService->addLogEntry( + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(SalesChannelDefinition::ENTITY_NAME) + ->withFieldName('paymentMethodId') + ->withFieldSourcePath('default_payment_method') + ->withSourceData($data) + ->withConvertedData($converted) + ->build(EmptyNecessaryFieldRunLog::class) + ); return null; } @@ -421,12 +433,15 @@ protected function setShippingMethodUuid(array &$data, array &$converted): ?stri ); if ($shippingMethodMapping === null) { - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $this->runId, - DefaultEntities::SALES_CHANNEL, - $this->oldIdentifier, - 'shipping methods' - )); + $this->loggingService->addLogEntry( + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(SalesChannelDefinition::ENTITY_NAME) + ->withFieldName('shippingMethodId') + ->withFieldSourcePath('default_shipping_method') + ->withSourceData($data) + ->withConvertedData($converted) + ->build(EmptyNecessaryFieldRunLog::class) + ); return null; } diff --git a/src/Profile/Magento2/Gateway/Local/Magento2LocalGateway.php b/src/Profile/Magento2/Gateway/Local/Magento2LocalGateway.php index 6282ade6..52506df2 100644 --- a/src/Profile/Magento2/Gateway/Local/Magento2LocalGateway.php +++ b/src/Profile/Magento2/Gateway/Local/Magento2LocalGateway.php @@ -320,12 +320,8 @@ public function readStores(MigrationContextInterface $migrationContext): array protected function getTablePrefixFromCredentials(MigrationContextInterface $migrationContext): string { $tablePrefix = ''; - $connection = $migrationContext->getConnection(); - if ($connection === null) { - return $tablePrefix; - } + $credentials = $migrationContext->getConnection()->getCredentialFields(); - $credentials = $connection->getCredentialFields(); if (isset($credentials['tablePrefix'])) { $tablePrefix = $credentials['tablePrefix']; } diff --git a/src/Profile/Magento2/Gateway/Local/Reader/Magento2NotAssociatedMediaReader.php b/src/Profile/Magento2/Gateway/Local/Reader/Magento2NotAssociatedMediaReader.php index 51b8f882..cc43bd91 100644 --- a/src/Profile/Magento2/Gateway/Local/Reader/Magento2NotAssociatedMediaReader.php +++ b/src/Profile/Magento2/Gateway/Local/Reader/Magento2NotAssociatedMediaReader.php @@ -18,12 +18,8 @@ abstract class Magento2NotAssociatedMediaReader extends NotAssociatedMediaReader public function read(MigrationContextInterface $migrationContext, array $params = []): array { - $connection = $migrationContext->getConnection(); - if ($connection === null) { - return []; - } + $credentialFields = $migrationContext->getConnection()->getCredentialFields(); - $credentialFields = $connection->getCredentialFields(); if ($credentialFields === null) { return []; } diff --git a/src/Profile/Magento20/Gateway/Local/Magento20LocalGateway.php b/src/Profile/Magento20/Gateway/Local/Magento20LocalGateway.php index bf1f76e4..4cf777f0 100644 --- a/src/Profile/Magento20/Gateway/Local/Magento20LocalGateway.php +++ b/src/Profile/Magento20/Gateway/Local/Magento20LocalGateway.php @@ -10,13 +10,13 @@ use Shopware\Core\Framework\Log\Package; use Swag\MigrationMagento\Profile\Magento2\Gateway\Local\Magento2LocalGateway; use Swag\MigrationMagento\Profile\Magento20\Magento20Profile; -use SwagMigrationAssistant\Migration\MigrationContextInterface; +use SwagMigrationAssistant\Migration\Profile\ProfileInterface; #[Package('fundamentals@after-sales')] class Magento20LocalGateway extends Magento2LocalGateway { - public function supports(MigrationContextInterface $migrationContext): bool + public function supports(ProfileInterface $profile): bool { - return $migrationContext->getProfile() instanceof Magento20Profile; + return $profile instanceof Magento20Profile; } } diff --git a/src/Profile/Magento21/Gateway/Local/Magento21LocalGateway.php b/src/Profile/Magento21/Gateway/Local/Magento21LocalGateway.php index c1e20e9d..ab95dcc0 100644 --- a/src/Profile/Magento21/Gateway/Local/Magento21LocalGateway.php +++ b/src/Profile/Magento21/Gateway/Local/Magento21LocalGateway.php @@ -10,13 +10,13 @@ use Shopware\Core\Framework\Log\Package; use Swag\MigrationMagento\Profile\Magento2\Gateway\Local\Magento2LocalGateway; use Swag\MigrationMagento\Profile\Magento21\Magento21Profile; -use SwagMigrationAssistant\Migration\MigrationContextInterface; +use SwagMigrationAssistant\Migration\Profile\ProfileInterface; #[Package('fundamentals@after-sales')] class Magento21LocalGateway extends Magento2LocalGateway { - public function supports(MigrationContextInterface $migrationContext): bool + public function supports(ProfileInterface $profile): bool { - return $migrationContext->getProfile() instanceof Magento21Profile; + return $profile instanceof Magento21Profile; } } diff --git a/src/Profile/Magento22/Gateway/Local/Magento22LocalGateway.php b/src/Profile/Magento22/Gateway/Local/Magento22LocalGateway.php index 091e439a..c66be266 100644 --- a/src/Profile/Magento22/Gateway/Local/Magento22LocalGateway.php +++ b/src/Profile/Magento22/Gateway/Local/Magento22LocalGateway.php @@ -10,13 +10,13 @@ use Shopware\Core\Framework\Log\Package; use Swag\MigrationMagento\Profile\Magento2\Gateway\Local\Magento2LocalGateway; use Swag\MigrationMagento\Profile\Magento22\Magento22Profile; -use SwagMigrationAssistant\Migration\MigrationContextInterface; +use SwagMigrationAssistant\Migration\Profile\ProfileInterface; #[Package('fundamentals@after-sales')] class Magento22LocalGateway extends Magento2LocalGateway { - public function supports(MigrationContextInterface $migrationContext): bool + public function supports(ProfileInterface $profile): bool { - return $migrationContext->getProfile() instanceof Magento22Profile; + return $profile instanceof Magento22Profile; } } diff --git a/src/Profile/Magento23/Gateway/Local/Magento23LocalGateway.php b/src/Profile/Magento23/Gateway/Local/Magento23LocalGateway.php index 9108b326..c7f8d1e9 100644 --- a/src/Profile/Magento23/Gateway/Local/Magento23LocalGateway.php +++ b/src/Profile/Magento23/Gateway/Local/Magento23LocalGateway.php @@ -10,13 +10,13 @@ use Shopware\Core\Framework\Log\Package; use Swag\MigrationMagento\Profile\Magento2\Gateway\Local\Magento2LocalGateway; use Swag\MigrationMagento\Profile\Magento23\Magento23Profile; -use SwagMigrationAssistant\Migration\MigrationContextInterface; +use SwagMigrationAssistant\Migration\Profile\ProfileInterface; #[Package('fundamentals@after-sales')] class Magento23LocalGateway extends Magento2LocalGateway { - public function supports(MigrationContextInterface $migrationContext): bool + public function supports(ProfileInterface $profile): bool { - return $migrationContext->getProfile() instanceof Magento23Profile; + return $profile instanceof Magento23Profile; } } diff --git a/tests/Profile/Magento/Media/LocalMediaProcessorTest.php b/tests/Profile/Magento/Media/LocalMediaProcessorTest.php index e2bf401f..a587b29d 100644 --- a/tests/Profile/Magento/Media/LocalMediaProcessorTest.php +++ b/tests/Profile/Magento/Media/LocalMediaProcessorTest.php @@ -20,6 +20,7 @@ use Shopware\Core\Test\Stub\DataAbstractionLayer\StaticEntityRepository; use Swag\MigrationMagento\Profile\Magento\Media\LocalMediaProcessor; use Swag\MigrationMagento\Profile\Magento19\Magento19Profile; +use SwagMigrationAssistant\Migration\Connection\SwagMigrationConnectionEntity; use SwagMigrationAssistant\Migration\Logging\LoggingServiceInterface; use SwagMigrationAssistant\Migration\Media\MediaProcessWorkloadStruct; use SwagMigrationAssistant\Migration\Media\SwagMigrationMediaFileCollection; @@ -52,10 +53,11 @@ public function testCopyMediaFiles(): void } $migrationContext = new MigrationContext( + new SwagMigrationConnectionEntity(), new Magento19Profile(), null, - Uuid::randomHex(), null, + Uuid::randomHex(), 0, 100 ); @@ -69,7 +71,7 @@ public function testCopyMediaFiles(): void foreach ($result as $workload) { static::assertInstanceOf(MediaProcessWorkloadStruct::class, $workload); - static::assertEquals(MediaProcessWorkloadStruct::FINISH_STATE, $workload->getState()); + static::assertSame(MediaProcessWorkloadStruct::FINISH_STATE, $workload->getState()); } } @@ -107,7 +109,7 @@ private function createLocaleMediaProcessor(array $mediaFiles): LocalMediaProces static::assertStringStartsWith('/tmp/', $mediaFile->getFileName()); static::assertFileExists($mediaFile->getFileName()); static::assertSame($mediaFile->getFileSize(), \filesize($mediaFile->getFileName())); - static::assertEquals('jpg', $mediaFile->getFileExtension()); + static::assertSame('jpg', $mediaFile->getFileExtension()); static::assertIsString($destination); static::assertStringStartsWith('test', $destination); diff --git a/tests/Profile/Magento/Premapping/PaymentMethodReaderTest.php b/tests/Profile/Magento/Premapping/PaymentMethodReaderTest.php index 97581ead..c9b9e135 100644 --- a/tests/Profile/Magento/Premapping/PaymentMethodReaderTest.php +++ b/tests/Profile/Magento/Premapping/PaymentMethodReaderTest.php @@ -97,8 +97,8 @@ protected function setUp(): void $gatewayRegistryMock->method('getGateway')->willReturn($gatewayMock); $this->migrationContext = new MigrationContext( + $connection, new Magento19Profile(), - $connection ); $this->reader = new Magento19PaymentMethodReader($gatewayRegistryMock, $mock); diff --git a/tests/Profile/Magento/Premapping/SalutationReaderTest.php b/tests/Profile/Magento/Premapping/SalutationReaderTest.php index d76b678a..67b3640f 100644 --- a/tests/Profile/Magento/Premapping/SalutationReaderTest.php +++ b/tests/Profile/Magento/Premapping/SalutationReaderTest.php @@ -95,8 +95,8 @@ protected function setUp(): void $gatewayRegistryMock->method('getGateway')->willReturn($gatewayMock); $this->migrationContext = new MigrationContext( + $connection, new Magento19Profile(), - $connection ); $this->reader = new Magento19SalutationReader($gatewayRegistryMock, $mock); diff --git a/tests/Profile/Magento/Premapping/ShippingMethodReaderTest.php b/tests/Profile/Magento/Premapping/ShippingMethodReaderTest.php index 9e114eec..0c5cff64 100644 --- a/tests/Profile/Magento/Premapping/ShippingMethodReaderTest.php +++ b/tests/Profile/Magento/Premapping/ShippingMethodReaderTest.php @@ -92,8 +92,8 @@ protected function setUp(): void $gatewayRegistryMock->method('getGateway')->willReturn($gatewayMock); $this->migrationContext = new MigrationContext( + $connection, new Magento19Profile(), - $connection ); $this->reader = new Magento19ShippingMethodReader($gatewayRegistryMock, $mock); diff --git a/tests/Profile/Magento19/Converter/Magento19CategoryConverterTest.php b/tests/Profile/Magento19/Converter/Magento19CategoryConverterTest.php index f73ab0d0..5f4e8e71 100644 --- a/tests/Profile/Magento19/Converter/Magento19CategoryConverterTest.php +++ b/tests/Profile/Magento19/Converter/Magento19CategoryConverterTest.php @@ -78,10 +78,11 @@ protected function setUp(): void ); $this->migrationContext = new MigrationContext( - new Magento19Profile(), $this->connection, - $this->runId, + new Magento19Profile(), + null, new CategoryDataSet(), + $this->runId, 0, 250 ); @@ -216,8 +217,6 @@ public function testConvertWithoutLocale(): void static::assertNull($convertResult->getConverted()); $logs = $this->loggingService->getLoggingArray(); - $title = 'The category entity has one or more empty necessary fields'; - static::assertSame($title, $logs[0]['title']); static::assertCount(1, $logs); } } diff --git a/tests/Profile/Magento19/Converter/Magento19CountryConverterTest.php b/tests/Profile/Magento19/Converter/Magento19CountryConverterTest.php index a41c2127..8031c997 100644 --- a/tests/Profile/Magento19/Converter/Magento19CountryConverterTest.php +++ b/tests/Profile/Magento19/Converter/Magento19CountryConverterTest.php @@ -68,10 +68,11 @@ protected function setUp(): void $this->connection->setName('shopware'); $this->migrationContext = new MigrationContext( - new Magento19Profile(), $this->connection, - $this->runId, + new Magento19Profile(), + null, new CountryDataSet(), + $this->runId, 0, 250 ); diff --git a/tests/Profile/Magento19/Converter/Magento19CrossSellingConverterTest.php b/tests/Profile/Magento19/Converter/Magento19CrossSellingConverterTest.php index 3de99780..f7096ffb 100644 --- a/tests/Profile/Magento19/Converter/Magento19CrossSellingConverterTest.php +++ b/tests/Profile/Magento19/Converter/Magento19CrossSellingConverterTest.php @@ -85,10 +85,11 @@ protected function setUp(): void $this->connection->setName('shopware'); $this->migrationContext = new MigrationContext( - new Magento19Profile(), $this->connection, - $this->runId, + new Magento19Profile(), + null, new CrossSellingDataSet(), + $this->runId, 0, 250 ); @@ -164,8 +165,7 @@ public function testConvertWithoutMapping(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame('SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING_PRODUCT', $logs[0]['code']); - static::assertSame('99', $logs[0]['parameters']['sourceId']); + static::assertSame('SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING', $logs[0]['code']); $this->loggingService->resetLogging(); $data[0]['linked_product_id'] = '80'; @@ -176,8 +176,7 @@ public function testConvertWithoutMapping(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame('SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING_PRODUCT', $logs[0]['code']); - static::assertSame('80', $logs[0]['parameters']['sourceId']); + static::assertSame('SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING', $logs[0]['code']); } private function createMapping(array $identifiers): void diff --git a/tests/Profile/Magento19/Converter/Magento19CurrencyConverterTest.php b/tests/Profile/Magento19/Converter/Magento19CurrencyConverterTest.php index ed3ea350..164df0dd 100644 --- a/tests/Profile/Magento19/Converter/Magento19CurrencyConverterTest.php +++ b/tests/Profile/Magento19/Converter/Magento19CurrencyConverterTest.php @@ -68,10 +68,11 @@ protected function setUp(): void $this->connection->setName('shopware'); $this->migrationContext = new MigrationContext( - new Magento19Profile(), $this->connection, - $this->runId, + new Magento19Profile(), + null, new CurrencyDataSet(), + $this->runId, 0, 250 ); diff --git a/tests/Profile/Magento19/Converter/Magento19CustomerConverterTest.php b/tests/Profile/Magento19/Converter/Magento19CustomerConverterTest.php index 4420f0d7..a5c00596 100644 --- a/tests/Profile/Magento19/Converter/Magento19CustomerConverterTest.php +++ b/tests/Profile/Magento19/Converter/Magento19CustomerConverterTest.php @@ -91,10 +91,11 @@ protected function setUp(): void $this->connection->setName('shopware'); $this->migrationContext = new MigrationContext( - new Magento19Profile(), $this->connection, - $this->runId, + new Magento19Profile(), + null, new CustomerDataSet(), + $this->runId, 0, 250 ); @@ -263,8 +264,7 @@ public function testConvertWithoutRequiredProperties(string $property, ?string $ $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_CUSTOMER'); - static::assertSame($logs[0]['parameters']['emptyField'], $property); + static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD'); } public function testConvertCustomerWithoutNumber(): void @@ -308,11 +308,10 @@ public function testConvertCustomerWithoutAddresses(): void static::assertNull($convertResult->getConverted()); $logs = $this->loggingService->getLoggingArray(); - static::assertCount(1, $logs); + static::assertCount(2, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_CUSTOMER'); - static::assertSame($logs[0]['parameters']['sourceId'], $customerData['entity_id']); - static::assertSame($logs[0]['parameters']['emptyField'], 'address data'); + static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD'); + static::assertSame($logs[1]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD'); } public function testConvertCustomerWithoutValidAddresses(): void @@ -332,15 +331,11 @@ public function testConvertCustomerWithoutValidAddresses(): void static::assertNull($convertResult->getConverted()); $logs = $this->loggingService->getLoggingArray(); - static::assertCount(2, $logs); - - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_CUSTOMER_ADDRESS'); - static::assertSame($logs[0]['parameters']['sourceId'], $customerData['addresses'][0]['entity_id']); - static::assertSame($logs[0]['parameters']['emptyField'], 'firstname'); + static::assertCount(3, $logs); - static::assertSame($logs[1]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_CUSTOMER'); - static::assertSame($logs[1]['parameters']['sourceId'], $customerData['entity_id']); - static::assertSame($logs[1]['parameters']['emptyField'], 'address data'); + 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_EMPTY_NECESSARY_FIELD'); } public static function requiredAddressProperties(): array @@ -393,13 +388,8 @@ public function testConvertWithoutRequiredAddressPropertiesForBillingDefault(str $logs = $this->loggingService->getLoggingArray(); static::assertCount(2, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_CUSTOMER_ADDRESS'); - static::assertSame($logs[0]['parameters']['sourceId'], $customerData['addresses'][0]['entity_id']); - static::assertSame($logs[0]['parameters']['emptyField'], $property); - - static::assertSame($logs[1]['code'], 'SWAG_MIGRATION_CUSTOMER_ENTITY_FIELD_REASSIGNED'); - static::assertSame($logs[1]['parameters']['emptyField'], 'default billing address'); - static::assertSame($logs[1]['parameters']['replacementField'], 'default shipping address'); + static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD'); + static::assertSame($logs[1]['code'], 'SWAG_MIGRATION_ENTITY_FIELD_REASSIGNED'); } #[DataProvider('requiredAddressProperties')] @@ -430,13 +420,8 @@ public function testConvertWithoutRequiredAddressPropertiesForShippingDefault(st $logs = $this->loggingService->getLoggingArray(); static::assertCount(2, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_CUSTOMER_ADDRESS'); - static::assertSame($logs[0]['parameters']['sourceId'], $customerData['addresses'][1]['entity_id']); - static::assertSame($logs[0]['parameters']['emptyField'], $property); - - static::assertSame($logs[1]['code'], 'SWAG_MIGRATION_CUSTOMER_ENTITY_FIELD_REASSIGNED'); - static::assertSame($logs[1]['parameters']['emptyField'], 'default shipping address'); - static::assertSame($logs[1]['parameters']['replacementField'], 'default billing address'); + static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD'); + static::assertSame($logs[1]['code'], 'SWAG_MIGRATION_ENTITY_FIELD_REASSIGNED'); } #[DataProvider('requiredAddressProperties')] @@ -466,19 +451,12 @@ public function testConvertWithoutRequiredAddressPropertiesForDefaultBillingAndS static::assertSame($converted['addresses'][0]['id'], $converted['defaultShippingAddressId']); $logs = $this->loggingService->getLoggingArray(); - static::assertCount(3, $logs); - - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_CUSTOMER_ADDRESS'); - static::assertSame($logs[0]['parameters']['sourceId'], $customerData['addresses'][0]['entity_id']); - static::assertSame($logs[0]['parameters']['emptyField'], $property); - - static::assertSame($logs[1]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_CUSTOMER_ADDRESS'); - static::assertSame($logs[1]['parameters']['sourceId'], $customerData['addresses'][1]['entity_id']); - static::assertSame($logs[1]['parameters']['emptyField'], $property); + static::assertCount(4, $logs); - static::assertSame($logs[2]['code'], 'SWAG_MIGRATION_CUSTOMER_ENTITY_FIELD_REASSIGNED'); - static::assertSame($logs[2]['parameters']['emptyField'], 'default billing and shipping address'); - static::assertSame($logs[2]['parameters']['replacementField'], 'first address'); + 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[3]['code'], 'SWAG_MIGRATION_ENTITY_FIELD_REASSIGNED'); } public function testConvertCountryStateWithMapping(): void @@ -560,10 +538,6 @@ public function testConvertNotExistingCountryStateWithoutMapping(): void static::assertCount(1, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_COUNTRY_STATE_ENTITY_UNKNOWN'); - static::assertSame($logs[0]['parameters']['sourceId'], '9999'); - static::assertSame($logs[0]['parameters']['entity'], DefaultEntities::COUNTRY_STATE); - static::assertSame($logs[0]['parameters']['requiredForSourceId'], $customerData['entity_id']); - static::assertSame($logs[0]['parameters']['requiredForEntity'], DefaultEntities::CUSTOMER); + static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_ENTITY_UNKNOWN'); } } diff --git a/tests/Profile/Magento19/Converter/Magento19CustomerGroupConverterTest.php b/tests/Profile/Magento19/Converter/Magento19CustomerGroupConverterTest.php index 4bf25e60..d9a5a13f 100644 --- a/tests/Profile/Magento19/Converter/Magento19CustomerGroupConverterTest.php +++ b/tests/Profile/Magento19/Converter/Magento19CustomerGroupConverterTest.php @@ -49,10 +49,11 @@ protected function setUp(): void $this->connection->setName('shopware'); $this->migrationContext = new MigrationContext( - new Magento19Profile(), $this->connection, - $this->runId, + new Magento19Profile(), + null, new CustomerGroupDataSet(), + $this->runId, 0, 250 ); diff --git a/tests/Profile/Magento19/Converter/Magento19LanguageConverterTest.php b/tests/Profile/Magento19/Converter/Magento19LanguageConverterTest.php index 0615d20c..33723946 100644 --- a/tests/Profile/Magento19/Converter/Magento19LanguageConverterTest.php +++ b/tests/Profile/Magento19/Converter/Magento19LanguageConverterTest.php @@ -65,10 +65,11 @@ protected function setUp(): void $this->connection->setName('shopware'); $this->migrationContext = new MigrationContext( - new Magento19Profile(), $this->connection, - $this->runId, + new Magento19Profile(), + null, new LanguageDataSet(), + $this->runId, 0, 250 ); diff --git a/tests/Profile/Magento19/Converter/Magento19ManufacturerConverterTest.php b/tests/Profile/Magento19/Converter/Magento19ManufacturerConverterTest.php index 8f0eed3b..ba774861 100644 --- a/tests/Profile/Magento19/Converter/Magento19ManufacturerConverterTest.php +++ b/tests/Profile/Magento19/Converter/Magento19ManufacturerConverterTest.php @@ -55,10 +55,11 @@ protected function setUp(): void $this->connection->setName('shopware'); $this->migrationContext = new MigrationContext( - new Magento19Profile(), $this->connection, - $this->runId, + new Magento19Profile(), + null, new ManufacturerDataSet(), + $this->runId, 0, 250 ); diff --git a/tests/Profile/Magento19/Converter/Magento19MediaConverterTest.php b/tests/Profile/Magento19/Converter/Magento19MediaConverterTest.php index f1c469f4..d06e4271 100644 --- a/tests/Profile/Magento19/Converter/Magento19MediaConverterTest.php +++ b/tests/Profile/Magento19/Converter/Magento19MediaConverterTest.php @@ -60,10 +60,11 @@ protected function setUp(): void $this->connection->setName('shopware'); $this->migrationContext = new MigrationContext( - new Magento19Profile(), $this->connection, - $this->runId, + new Magento19Profile(), + null, new MediaDataSet(), + $this->runId, 0, 250 ); diff --git a/tests/Profile/Magento19/Converter/Magento19NewsletterRecipientConverterTest.php b/tests/Profile/Magento19/Converter/Magento19NewsletterRecipientConverterTest.php index 39fa923a..bb6feea1 100644 --- a/tests/Profile/Magento19/Converter/Magento19NewsletterRecipientConverterTest.php +++ b/tests/Profile/Magento19/Converter/Magento19NewsletterRecipientConverterTest.php @@ -92,10 +92,11 @@ protected function setUp(): void $this->newsletterRecipientConverter = new Magento19NewsletterRecipientConverter($this->mappingService, $this->loggingService); $this->migrationContext = new MigrationContext( - new Magento19Profile(), $this->connection, - $this->runId, + new Magento19Profile(), + null, new NewsletterRecipientDataSet(), + $this->runId, 0, 250 ); @@ -138,8 +139,7 @@ public function testConvertWithInvalidLanguage(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING_LANGUAGE'); - static::assertSame($newsletterRecipientData[0]['store_id'], $logs[0]['parameters']['sourceId']); + static::assertSame($logs[0]['code'], 'SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING'); } public function testConvertWithInvalidSalesChannel(): void @@ -165,8 +165,6 @@ public function testConvertWithInvalidSalesChannel(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_NEWSLETTER_RECIPIENT'); - static::assertSame($newsletterRecipientData[0]['subscriber_id'], $logs[0]['parameters']['sourceId']); - static::assertSame('salesChannel', $logs[0]['parameters']['emptyField']); + static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD'); } } diff --git a/tests/Profile/Magento19/Converter/Magento19NotAssociatedMediaConverterTest.php b/tests/Profile/Magento19/Converter/Magento19NotAssociatedMediaConverterTest.php index c905f50c..48bdf01d 100644 --- a/tests/Profile/Magento19/Converter/Magento19NotAssociatedMediaConverterTest.php +++ b/tests/Profile/Magento19/Converter/Magento19NotAssociatedMediaConverterTest.php @@ -51,10 +51,11 @@ protected function setUp(): void $this->connection->setName('shopware'); $this->migrationContext = new MigrationContext( - new Magento19Profile(), $this->connection, - $this->runId, + new Magento19Profile(), + null, new NotAssociatedMediaDataSet(), + $this->runId, 0, 250 ); diff --git a/tests/Profile/Magento19/Converter/Magento19OrderConverterTest.php b/tests/Profile/Magento19/Converter/Magento19OrderConverterTest.php index fed808af..c9e1d5b7 100644 --- a/tests/Profile/Magento19/Converter/Magento19OrderConverterTest.php +++ b/tests/Profile/Magento19/Converter/Magento19OrderConverterTest.php @@ -94,10 +94,11 @@ protected function setUp(): void $this->connection->setName('shopware'); $this->migrationContext = new MigrationContext( - new Magento19Profile(), $this->connection, - $this->runId, + new Magento19Profile(), + null, new OrderDataSet(), + $this->runId, 0, 250 ); @@ -343,9 +344,7 @@ public function testConvertWithInvalidSalutation(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_SALUTATION_ENTITY_UNKNOWN'); - static::assertSame($logs[0]['parameters']['sourceId'], $order['orders']['customer_salutation']); - static::assertSame($logs[0]['parameters']['requiredForSourceId'], $order['orders']['entity_id']); + static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_ENTITY_UNKNOWN'); } public function testConvertWithoutSalutation(): void @@ -380,9 +379,7 @@ public function testConvertWithInvalidCurrency(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_ORDER'); - static::assertSame($logs[0]['parameters']['sourceId'], $order['orders']['entity_id']); - static::assertSame($logs[0]['parameters']['emptyField'], 'currency'); + static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD'); } public function testConvertWithInvalidOrderState(): void @@ -400,26 +397,25 @@ public function testConvertWithInvalidOrderState(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_ORDER_STATE_ENTITY_UNKNOWN'); - static::assertSame($logs[0]['parameters']['sourceId'], $order['orders']['status']); + static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_ENTITY_UNKNOWN'); } public static function requiredProperties(): array { return [ - ['orders', null], - ['orders', ''], - ['billingAddress', null], - ['billingAddress', ''], - ['shippingAddress', null], - ['shippingAddress', ''], - ['items', null], - ['items', ''], + ['orders', 2, null], + ['orders', 2, ''], + ['billingAddress', 1, null], + ['billingAddress', 1, ''], + ['shippingAddress', 1, null], + ['shippingAddress', 1, ''], + ['items', 1, null], + ['items', 1, ''], ]; } #[DataProvider('requiredProperties')] - public function testConvertWithoutRequiredProperties(string $property, ?string $value): void + public function testConvertWithoutRequiredProperties(string $property, int $expected, ?string $value): void { $orderData = require __DIR__ . '/../../../_fixtures/order_data.php'; $orderData = $orderData[0]; @@ -430,15 +426,7 @@ public function testConvertWithoutRequiredProperties(string $property, ?string $ static::assertNull($convertResult->getConverted()); $logs = $this->loggingService->getLoggingArray(); - static::assertCount(1, $logs); - - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_ORDER'); - - if ($property === 'orders') { - static::assertSame($logs[0]['parameters']['emptyField'], 'orders,entity_id'); - } else { - static::assertSame($logs[0]['parameters']['emptyField'], $property); - } + static::assertCount($expected, $logs); } public function testConvertWithRepeatedGuestMigration(): void @@ -549,10 +537,6 @@ public function testConvertNotExistingCountryStateWithoutMapping(): void static::assertCount(1, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_COUNTRY_STATE_ENTITY_UNKNOWN'); - static::assertSame($logs[0]['parameters']['sourceId'], '9999'); - static::assertSame($logs[0]['parameters']['entity'], DefaultEntities::COUNTRY_STATE); - static::assertSame($logs[0]['parameters']['requiredForSourceId'], $orderData['identifier']); - static::assertSame($logs[0]['parameters']['requiredForEntity'], DefaultEntities::ORDER); + static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_ENTITY_UNKNOWN'); } } diff --git a/tests/Profile/Magento19/Converter/Magento19ProductChildMultiSelectPropertyRelationConverterTest.php b/tests/Profile/Magento19/Converter/Magento19ProductChildMultiSelectPropertyRelationConverterTest.php index 5f31fc10..7cac00fd 100644 --- a/tests/Profile/Magento19/Converter/Magento19ProductChildMultiSelectPropertyRelationConverterTest.php +++ b/tests/Profile/Magento19/Converter/Magento19ProductChildMultiSelectPropertyRelationConverterTest.php @@ -51,10 +51,11 @@ protected function setUp(): void $this->connection->setName('shopware'); $this->migrationContext = new MigrationContext( - new Magento19Profile(), $this->connection, - $this->runId, + new Magento19Profile(), + null, new ProductChildMultiSelectPropertyRelationDataSet(), + $this->runId, 0, 250 ); diff --git a/tests/Profile/Magento19/Converter/Magento19ProductChildPropertyRelationTest.php b/tests/Profile/Magento19/Converter/Magento19ProductChildPropertyRelationTest.php index 1f84d395..1f412304 100644 --- a/tests/Profile/Magento19/Converter/Magento19ProductChildPropertyRelationTest.php +++ b/tests/Profile/Magento19/Converter/Magento19ProductChildPropertyRelationTest.php @@ -51,10 +51,11 @@ protected function setUp(): void $this->connection->setName('shopware'); $this->migrationContext = new MigrationContext( - new Magento19Profile(), $this->connection, - $this->runId, + new Magento19Profile(), + null, new ProductChildPropertyRelationDataSet(), + $this->runId, 0, 250 ); diff --git a/tests/Profile/Magento19/Converter/Magento19ProductConverterTest.php b/tests/Profile/Magento19/Converter/Magento19ProductConverterTest.php index 240d9d45..869a0697 100644 --- a/tests/Profile/Magento19/Converter/Magento19ProductConverterTest.php +++ b/tests/Profile/Magento19/Converter/Magento19ProductConverterTest.php @@ -67,10 +67,11 @@ protected function setUp(): void $this->connection->setName('shopware'); $this->migrationContext = new MigrationContext( - new Magento19Profile(), $this->connection, - $this->runId, + new Magento19Profile(), + null, new ProductDataSet(), + $this->runId, 0, 250 ); @@ -295,9 +296,7 @@ public function testConvertWithoutTax(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_PRODUCT'); - static::assertSame($logs[0]['parameters']['sourceId'], $product['entity_id']); - static::assertSame($logs[0]['parameters']['emptyField'], 'tax class'); + static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD'); } public function testConvertWithInvalidTax(): void @@ -315,8 +314,7 @@ public function testConvertWithInvalidTax(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_TAX_ENTITY_UNKNOWN'); - static::assertSame($logs[0]['parameters']['sourceId'], $product['tax_class_id']); + static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_ENTITY_UNKNOWN'); } public function testConvertWithoutPrice(): void @@ -334,9 +332,7 @@ public function testConvertWithoutPrice(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_PRODUCT'); - static::assertSame($logs[0]['parameters']['sourceId'], $product['entity_id']); - static::assertSame($logs[0]['parameters']['emptyField'], 'price'); + static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD'); } public function testConvertWithoutDefaultCurrency(): void @@ -355,9 +351,7 @@ public function testConvertWithoutDefaultCurrency(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_PRODUCT'); - static::assertSame($logs[0]['parameters']['sourceId'], $product['entity_id']); - static::assertSame($logs[0]['parameters']['emptyField'], 'currency'); + static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD'); } public function testConvertWithZeroMinPurchase(): void diff --git a/tests/Profile/Magento19/Converter/Magento19ProductCustomFieldConverterTest.php b/tests/Profile/Magento19/Converter/Magento19ProductCustomFieldConverterTest.php index 6854a802..0926fd8e 100644 --- a/tests/Profile/Magento19/Converter/Magento19ProductCustomFieldConverterTest.php +++ b/tests/Profile/Magento19/Converter/Magento19ProductCustomFieldConverterTest.php @@ -49,10 +49,11 @@ protected function setUp(): void $this->connection->setName('shopware'); $this->migrationContext = new MigrationContext( - new Magento19Profile(), $this->connection, - $this->runId, + new Magento19Profile(), + null, new ProductCustomFieldDataSet(), + $this->runId, 0, 250 ); diff --git a/tests/Profile/Magento19/Converter/Magento19ProductMultiSelectPropertyRelationConvertTest.php b/tests/Profile/Magento19/Converter/Magento19ProductMultiSelectPropertyRelationConvertTest.php index f78aa3e4..5406443d 100644 --- a/tests/Profile/Magento19/Converter/Magento19ProductMultiSelectPropertyRelationConvertTest.php +++ b/tests/Profile/Magento19/Converter/Magento19ProductMultiSelectPropertyRelationConvertTest.php @@ -51,10 +51,11 @@ protected function setUp(): void $this->connection->setName('shopware'); $this->migrationContext = new MigrationContext( - new Magento19Profile(), $this->connection, - $this->runId, + new Magento19Profile(), + null, new ProductMultiSelectPropertyRelationDataSet(), + $this->runId, 0, 250 ); diff --git a/tests/Profile/Magento19/Converter/Magento19ProductMultiSelectPropertyRelationConverterTest.php b/tests/Profile/Magento19/Converter/Magento19ProductMultiSelectPropertyRelationConverterTest.php index 57b7b8d8..5ac07366 100644 --- a/tests/Profile/Magento19/Converter/Magento19ProductMultiSelectPropertyRelationConverterTest.php +++ b/tests/Profile/Magento19/Converter/Magento19ProductMultiSelectPropertyRelationConverterTest.php @@ -51,10 +51,11 @@ protected function setUp(): void $this->connection->setName('shopware'); $this->migrationContext = new MigrationContext( - new Magento19Profile(), $this->connection, - $this->runId, + new Magento19Profile(), + null, new ProductMultiSelectPropertyRelationDataSet(), + $this->runId, 0, 250 ); diff --git a/tests/Profile/Magento19/Converter/Magento19ProductOptionRelationConvertTest.php b/tests/Profile/Magento19/Converter/Magento19ProductOptionRelationConvertTest.php index 0e32795e..b5f2a852 100644 --- a/tests/Profile/Magento19/Converter/Magento19ProductOptionRelationConvertTest.php +++ b/tests/Profile/Magento19/Converter/Magento19ProductOptionRelationConvertTest.php @@ -51,10 +51,11 @@ protected function setUp(): void $this->connection->setName('shopware'); $this->migrationContext = new MigrationContext( - new Magento19Profile(), $this->connection, - $this->runId, + new Magento19Profile(), + null, new ProductOptionRelationDataSet(), + $this->runId, 0, 250 ); diff --git a/tests/Profile/Magento19/Converter/Magento19ProductPropertyRelationConvertTest.php b/tests/Profile/Magento19/Converter/Magento19ProductPropertyRelationConvertTest.php index 7e1f5611..a897536a 100644 --- a/tests/Profile/Magento19/Converter/Magento19ProductPropertyRelationConvertTest.php +++ b/tests/Profile/Magento19/Converter/Magento19ProductPropertyRelationConvertTest.php @@ -51,10 +51,11 @@ protected function setUp(): void $this->connection->setName('shopware'); $this->migrationContext = new MigrationContext( - new Magento19Profile(), $this->connection, - $this->runId, + new Magento19Profile(), + null, new ProductPropertyRelationDataSet(), + $this->runId, 0, 250 ); diff --git a/tests/Profile/Magento19/Converter/Magento19ProductReviewConverterTest.php b/tests/Profile/Magento19/Converter/Magento19ProductReviewConverterTest.php index 29629a0e..c31abeac 100644 --- a/tests/Profile/Magento19/Converter/Magento19ProductReviewConverterTest.php +++ b/tests/Profile/Magento19/Converter/Magento19ProductReviewConverterTest.php @@ -53,10 +53,11 @@ protected function setUp(): void $this->connection->setName('shopware'); $this->migrationContext = new MigrationContext( - new Magento19Profile(), $this->connection, - $this->runId, + new Magento19Profile(), + null, new ProductReviewDataSet(), + $this->runId, 0, 250 ); @@ -140,8 +141,7 @@ public function testConvertWithoutProductMapping(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING_PRODUCT'); - static::assertSame($logs[0]['parameters']['sourceId'], $productReviewData[0]['productId']); + static::assertSame($logs[0]['code'], 'SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING'); } public function testConvertWithoutCustomerMapping(): void @@ -174,8 +174,7 @@ public function testConvertWithoutSalesChannelMapping(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING_SALES_CHANNEL'); - static::assertSame($logs[0]['parameters']['sourceId'], $productReviewData[0]['store_id']); + static::assertSame($logs[0]['code'], 'SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING'); } public function testConvertWithoutLanguageMapping(): void @@ -193,7 +192,6 @@ public function testConvertWithoutLanguageMapping(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING_STORE_LANGUAGE'); - static::assertSame($logs[0]['parameters']['sourceId'], $productReviewData[0]['store_id']); + static::assertSame($logs[0]['code'], 'SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING'); } } diff --git a/tests/Profile/Magento19/Converter/Magento19PropertyGroupConverterTest.php b/tests/Profile/Magento19/Converter/Magento19PropertyGroupConverterTest.php index e259ee89..ae21516d 100644 --- a/tests/Profile/Magento19/Converter/Magento19PropertyGroupConverterTest.php +++ b/tests/Profile/Magento19/Converter/Magento19PropertyGroupConverterTest.php @@ -71,10 +71,11 @@ protected function setUp(): void ); $this->migrationContext = new MigrationContext( - new Magento19Profile(), $this->connection, - $this->runId, + new Magento19Profile(), + null, new PropertyGroupDataSet(), + $this->runId, 0, 250 ); @@ -149,8 +150,6 @@ public function testConvertWithoutName(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_PROPERTY_GROUP'); - static::assertSame($logs[0]['parameters']['sourceId'], $propertyGroupData[0]['id']); - static::assertSame($logs[0]['parameters']['emptyField'], 'group name'); + static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD'); } } diff --git a/tests/Profile/Magento19/Converter/Magento19SalesChannelConverterTest.php b/tests/Profile/Magento19/Converter/Magento19SalesChannelConverterTest.php index bdf94ffd..e08771fe 100644 --- a/tests/Profile/Magento19/Converter/Magento19SalesChannelConverterTest.php +++ b/tests/Profile/Magento19/Converter/Magento19SalesChannelConverterTest.php @@ -74,10 +74,11 @@ protected function setUp(): void $this->connection->setName('shopware'); $this->migrationContext = new MigrationContext( - new Magento19Profile(), $this->connection, - $this->runId, + new Magento19Profile(), + null, new SalesChannelDataSet(), + $this->runId, 0, 250 ); @@ -160,10 +161,7 @@ public function testConvertWithoutDefaultLanguage(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame('SWAG_MIGRATION_SALES_CHANNEL_ENTITY_FIELD_REASSIGNED', $logs[0]['code']); - static::assertSame($salesChannelData[0]['group_id'], $logs[0]['parameters']['sourceId']); - static::assertSame('defaultLocale', $logs[0]['parameters']['emptyField']); - static::assertSame('system default language', $logs[0]['parameters']['replacementField']); + static::assertSame('SWAG_MIGRATION_ENTITY_FIELD_REASSIGNED', $logs[0]['code']); static::assertSame(DummyMagentoMappingService::DEFAULT_LANGUAGE_UUID, $converted['languageId']); } @@ -183,10 +181,7 @@ public function testConvertWithoutDefaultCurrency(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame('SWAG_MIGRATION_SALES_CHANNEL_ENTITY_FIELD_REASSIGNED', $logs[0]['code']); - static::assertSame($salesChannelData[0]['group_id'], $logs[0]['parameters']['sourceId']); - static::assertSame('defaultCurrency', $logs[0]['parameters']['emptyField']); - static::assertSame('system default currency', $logs[0]['parameters']['replacementField']); + static::assertSame('SWAG_MIGRATION_ENTITY_FIELD_REASSIGNED', $logs[0]['code']); static::assertSame(Defaults::CURRENCY, $converted['currencyId']); } @@ -205,8 +200,7 @@ public function testConvertWithoutDefaultCategory(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING_CATEGORY'); - static::assertSame($logs[0]['parameters']['sourceId'], $salesChannelData[0]['root_category_id']); + static::assertSame($logs[0]['code'], 'SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING'); } public function testConvertMissingPaymentMethod(): void @@ -229,8 +223,7 @@ public function testConvertMissingPaymentMethod(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING_PAYMENT_METHOD'); - static::assertSame($logs[0]['parameters']['sourceId'], 'cashondelivery'); + static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD'); } public function testConvertMissingShippingMethod(): void @@ -253,8 +246,7 @@ public function testConvertMissingShippingMethod(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING_SHIPPING_METHOD'); - static::assertSame($logs[0]['parameters']['sourceId'], 'ups'); + static::assertSame($logs[0]['code'], 'SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING'); } public function testConvertMissingWithoutPaymentMethods(): void @@ -313,7 +305,6 @@ public function testConvertWithoutDefaultCustomerGroup(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING_CUSTOMER_GROUP'); - static::assertSame($logs[0]['parameters']['sourceId'], 'default_customer_group'); + static::assertSame($logs[0]['code'], 'SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING'); } } diff --git a/tests/Profile/Magento19/Converter/Magento19SeoUrlConverterTest.php b/tests/Profile/Magento19/Converter/Magento19SeoUrlConverterTest.php index 05b9cf86..5521898a 100644 --- a/tests/Profile/Magento19/Converter/Magento19SeoUrlConverterTest.php +++ b/tests/Profile/Magento19/Converter/Magento19SeoUrlConverterTest.php @@ -62,10 +62,11 @@ protected function setUp(): void $this->connection->setName('shopware'); $this->migrationContext = new MigrationContext( - new Magento19Profile(), $this->connection, - $this->runId, + new Magento19Profile(), + null, new SeoUrlDataSet(), + $this->runId, 0, 250 ); @@ -100,8 +101,7 @@ public function testConvertWithInvalidSalesChannel(): void static::assertNotNull($convertResult->getUnmapped()); static::assertNull($converted); static::assertCount(1, $logs); - static::assertSame('SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING_SALES_CHANNEL', $logs[0]['code']); - static::assertSame($seoUrlData[0]['store_id'], $logs[0]['parameters']['sourceId']); + static::assertSame('SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING', $logs[0]['code']); } public function testConvertWithInvalidLanguage(): void @@ -115,8 +115,7 @@ public function testConvertWithInvalidLanguage(): void static::assertNotNull($convertResult->getUnmapped()); static::assertNull($converted); static::assertCount(1, $logs); - static::assertSame('SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING_STORE_LANGUAGE', $logs[0]['code']); - static::assertSame($seoUrlData[0]['store_id'], $logs[0]['parameters']['sourceId']); + static::assertSame('SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING', $logs[0]['code']); } public function testConvertWithInvalidProduct(): void @@ -130,8 +129,7 @@ public function testConvertWithInvalidProduct(): void static::assertNotNull($convertResult->getUnmapped()); static::assertNull($converted); static::assertCount(1, $logs); - static::assertSame('SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING_PRODUCT', $logs[0]['code']); - static::assertSame($seoUrlData[0]['product_id'], $logs[0]['parameters']['sourceId']); + static::assertSame('SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING', $logs[0]['code']); } public function testConvertWithInvalidCategory(): void @@ -145,8 +143,7 @@ public function testConvertWithInvalidCategory(): void static::assertNotNull($convertResult->getUnmapped()); static::assertNull($converted); static::assertCount(1, $logs); - static::assertSame('SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING_CATEGORY', $logs[0]['code']); - static::assertSame($seoUrlData[0]['category_id'], $logs[0]['parameters']['sourceId']); + static::assertSame('SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING', $logs[0]['code']); } public function testConvertWithoutProductOrCategory(): void @@ -160,9 +157,7 @@ public function testConvertWithoutProductOrCategory(): void static::assertNotNull($convertResult->getUnmapped()); static::assertNull($converted); static::assertCount(1, $logs); - static::assertSame('SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_SEO_URL', $logs[0]['code']); - static::assertSame($seoUrlData[2]['url_rewrite_id'], $logs[0]['parameters']['sourceId']); - static::assertSame('category_id, product_id', $logs[0]['parameters']['emptyField']); + static::assertSame('SWAG_MIGRATION_EMPTY_NECESSARY_FIELD', $logs[0]['code']); } public function testConvertProductAndCategorySeoUrl(): void diff --git a/tests/Profile/Magento2/Converter/Magento2CategoryConverterTest.php b/tests/Profile/Magento2/Converter/Magento2CategoryConverterTest.php index 126b955b..2033a414 100644 --- a/tests/Profile/Magento2/Converter/Magento2CategoryConverterTest.php +++ b/tests/Profile/Magento2/Converter/Magento2CategoryConverterTest.php @@ -144,34 +144,38 @@ protected function setUp(): void ); $this->migrationContext20 = new MigrationContext( - new Magento20Profile(), $this->connection20, - $this->runId, + new Magento20Profile(), + null, new CategoryDataSet(), + $this->runId, 0, 250 ); $this->migrationContext21 = new MigrationContext( - new Magento21Profile(), $this->connection21, - $this->runId, + new Magento21Profile(), + null, new CategoryDataSet(), + $this->runId, 0, 250 ); $this->migrationContext22 = new MigrationContext( - new Magento22Profile(), $this->connection22, - $this->runId, + new Magento22Profile(), + null, new CategoryDataSet(), + $this->runId, 0, 250 ); $this->migrationContext23 = new MigrationContext( - new Magento23Profile(), $this->connection23, - $this->runId, + new Magento23Profile(), + null, new CategoryDataSet(), + $this->runId, 0, 250 ); @@ -513,8 +517,6 @@ public function testConvertWithoutLocale20(): void static::assertNull($convertResult->getConverted()); $logs = $this->loggingService->getLoggingArray(); - $title = 'The category entity has one or more empty necessary fields'; - static::assertSame($title, $logs[0]['title']); static::assertCount(1, $logs); } @@ -529,8 +531,6 @@ public function testConvertWithoutLocale21(): void static::assertNull($convertResult->getConverted()); $logs = $this->loggingService->getLoggingArray(); - $title = 'The category entity has one or more empty necessary fields'; - static::assertSame($title, $logs[0]['title']); static::assertCount(1, $logs); } @@ -545,8 +545,6 @@ public function testConvertWithoutLocale22(): void static::assertNull($convertResult->getConverted()); $logs = $this->loggingService->getLoggingArray(); - $title = 'The category entity has one or more empty necessary fields'; - static::assertSame($title, $logs[0]['title']); static::assertCount(1, $logs); } @@ -561,8 +559,6 @@ public function testConvertWithoutLocale23(): void static::assertNull($convertResult->getConverted()); $logs = $this->loggingService->getLoggingArray(); - $title = 'The category entity has one or more empty necessary fields'; - static::assertSame($title, $logs[0]['title']); static::assertCount(1, $logs); } } diff --git a/tests/Profile/Magento2/Converter/Magento2CountryConverterTest.php b/tests/Profile/Magento2/Converter/Magento2CountryConverterTest.php index 2a114728..3e1b85bd 100644 --- a/tests/Profile/Magento2/Converter/Magento2CountryConverterTest.php +++ b/tests/Profile/Magento2/Converter/Magento2CountryConverterTest.php @@ -64,10 +64,11 @@ protected function setUp(): void $this->connection->setName('shopware'); $this->migrationContext = new MigrationContext( - new Magento23Profile(), $this->connection, - $this->runId, + new Magento23Profile(), + null, new CountryDataSet(), + $this->runId, 0, 250 ); diff --git a/tests/Profile/Magento2/Converter/Magento2CrossSellingConverterTest.php b/tests/Profile/Magento2/Converter/Magento2CrossSellingConverterTest.php index a7f7208f..6da5864b 100644 --- a/tests/Profile/Magento2/Converter/Magento2CrossSellingConverterTest.php +++ b/tests/Profile/Magento2/Converter/Magento2CrossSellingConverterTest.php @@ -85,10 +85,11 @@ protected function setUp(): void $this->connection->setName('shopware'); $this->migrationContext = new MigrationContext( - new Magento23Profile(), $this->connection, - $this->runId, + new Magento23Profile(), + null, new CrossSellingDataSet(), + $this->runId, 0, 250 ); @@ -164,8 +165,7 @@ public function testConvertWithoutMapping(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame('SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING_PRODUCT', $logs[0]['code']); - static::assertSame('99', $logs[0]['parameters']['sourceId']); + static::assertSame('SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING', $logs[0]['code']); $this->loggingService->resetLogging(); $data[0]['linked_product_id'] = '80'; @@ -176,8 +176,7 @@ public function testConvertWithoutMapping(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame('SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING_PRODUCT', $logs[0]['code']); - static::assertSame('80', $logs[0]['parameters']['sourceId']); + static::assertSame('SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING', $logs[0]['code']); } private function createMapping(array $identifiers): void diff --git a/tests/Profile/Magento2/Converter/Magento2CurrencyConverterTest.php b/tests/Profile/Magento2/Converter/Magento2CurrencyConverterTest.php index 9e944e16..8be9b7ed 100644 --- a/tests/Profile/Magento2/Converter/Magento2CurrencyConverterTest.php +++ b/tests/Profile/Magento2/Converter/Magento2CurrencyConverterTest.php @@ -65,10 +65,11 @@ protected function setUp(): void $this->connection->setName('shopware'); $this->migrationContext = new MigrationContext( - new Magento23Profile(), $this->connection, - $this->runId, + new Magento23Profile(), + null, new CurrencyDataSet(), + $this->runId, 0, 250 ); diff --git a/tests/Profile/Magento2/Converter/Magento2CustomerConverterTest.php b/tests/Profile/Magento2/Converter/Magento2CustomerConverterTest.php index 5d310e44..ed9ac743 100644 --- a/tests/Profile/Magento2/Converter/Magento2CustomerConverterTest.php +++ b/tests/Profile/Magento2/Converter/Magento2CustomerConverterTest.php @@ -82,10 +82,11 @@ protected function setUp(): void $this->connection->setName('shopware'); $this->migrationContext = new MigrationContext( - new Magento23Profile(), $this->connection, - $this->runId, + new Magento23Profile(), + null, new CustomerDataSet(), + $this->runId, 0, 250 ); @@ -293,8 +294,7 @@ public function testConvertWithoutRequiredProperties(string $property, ?string $ $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_CUSTOMER'); - static::assertSame($logs[0]['parameters']['emptyField'], $property); + static::assertSame('SWAG_MIGRATION_EMPTY_NECESSARY_FIELD', $logs[0]['code']); } public function testConvertCustomerWithoutNumber(): void @@ -338,11 +338,10 @@ public function testConvertCustomerWithoutAddresses(): void static::assertNull($convertResult->getConverted()); $logs = $this->loggingService->getLoggingArray(); - static::assertCount(1, $logs); + static::assertCount(2, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_CUSTOMER'); - static::assertSame($logs[0]['parameters']['sourceId'], $customerData['entity_id']); - static::assertSame($logs[0]['parameters']['emptyField'], 'address data'); + static::assertSame('SWAG_MIGRATION_EMPTY_NECESSARY_FIELD', $logs[0]['code']); + static::assertSame('SWAG_MIGRATION_EMPTY_NECESSARY_FIELD', $logs[1]['code']); } public function testConvertCustomerWithoutValidAddresses(): void @@ -362,15 +361,11 @@ public function testConvertCustomerWithoutValidAddresses(): void static::assertNull($convertResult->getConverted()); $logs = $this->loggingService->getLoggingArray(); - static::assertCount(2, $logs); - - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_CUSTOMER_ADDRESS'); - static::assertSame($logs[0]['parameters']['sourceId'], $customerData['addresses'][0]['entity_id']); - static::assertSame($logs[0]['parameters']['emptyField'], 'firstname'); + static::assertCount(3, $logs); - static::assertSame($logs[1]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_CUSTOMER'); - static::assertSame($logs[1]['parameters']['sourceId'], $customerData['entity_id']); - static::assertSame($logs[1]['parameters']['emptyField'], 'address data'); + static::assertSame('SWAG_MIGRATION_EMPTY_NECESSARY_FIELD', $logs[0]['code']); + static::assertSame('SWAG_MIGRATION_EMPTY_NECESSARY_FIELD', $logs[1]['code']); + static::assertSame('SWAG_MIGRATION_EMPTY_NECESSARY_FIELD', $logs[2]['code']); } /** @@ -426,13 +421,9 @@ public function testConvertWithoutRequiredAddressPropertiesForBillingDefault(str $logs = $this->loggingService->getLoggingArray(); static::assertCount(2, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_CUSTOMER_ADDRESS'); - static::assertSame($logs[0]['parameters']['sourceId'], $customerData['addresses'][0]['entity_id']); - static::assertSame($logs[0]['parameters']['emptyField'], $property); + static::assertSame('SWAG_MIGRATION_EMPTY_NECESSARY_FIELD', $logs[0]['code']); - static::assertSame($logs[1]['code'], 'SWAG_MIGRATION_CUSTOMER_ENTITY_FIELD_REASSIGNED'); - static::assertSame($logs[1]['parameters']['emptyField'], 'default billing address'); - static::assertSame($logs[1]['parameters']['replacementField'], 'default shipping address'); + static::assertSame('SWAG_MIGRATION_ENTITY_FIELD_REASSIGNED', $logs[1]['code']); } #[DataProvider('requiredAddressProperties')] @@ -463,13 +454,8 @@ public function testConvertWithoutRequiredAddressPropertiesForShippingDefault(st $logs = $this->loggingService->getLoggingArray(); static::assertCount(2, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_CUSTOMER_ADDRESS'); - static::assertSame($logs[0]['parameters']['sourceId'], $customerData['addresses'][1]['entity_id']); - static::assertSame($logs[0]['parameters']['emptyField'], $property); - - static::assertSame($logs[1]['code'], 'SWAG_MIGRATION_CUSTOMER_ENTITY_FIELD_REASSIGNED'); - static::assertSame($logs[1]['parameters']['emptyField'], 'default shipping address'); - static::assertSame($logs[1]['parameters']['replacementField'], 'default billing address'); + static::assertSame('SWAG_MIGRATION_EMPTY_NECESSARY_FIELD', $logs[0]['code']); + static::assertSame('SWAG_MIGRATION_ENTITY_FIELD_REASSIGNED', $logs[1]['code']); } #[DataProvider('requiredAddressProperties')] @@ -499,18 +485,11 @@ public function testConvertWithoutRequiredAddressPropertiesForDefaultBillingAndS static::assertSame($converted['addresses'][0]['id'], $converted['defaultShippingAddressId']); $logs = $this->loggingService->getLoggingArray(); - static::assertCount(3, $logs); - - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_CUSTOMER_ADDRESS'); - static::assertSame($logs[0]['parameters']['sourceId'], $customerData['addresses'][0]['entity_id']); - static::assertSame($logs[0]['parameters']['emptyField'], $property); - - static::assertSame($logs[1]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_CUSTOMER_ADDRESS'); - static::assertSame($logs[1]['parameters']['sourceId'], $customerData['addresses'][1]['entity_id']); - static::assertSame($logs[1]['parameters']['emptyField'], $property); + static::assertCount(4, $logs); - static::assertSame($logs[2]['code'], 'SWAG_MIGRATION_CUSTOMER_ENTITY_FIELD_REASSIGNED'); - static::assertSame($logs[2]['parameters']['emptyField'], 'default billing and shipping address'); - static::assertSame($logs[2]['parameters']['replacementField'], 'first address'); + static::assertSame('SWAG_MIGRATION_EMPTY_NECESSARY_FIELD', $logs[0]['code']); + static::assertSame('SWAG_MIGRATION_EMPTY_NECESSARY_FIELD', $logs[1]['code']); + static::assertSame('SWAG_MIGRATION_ENTITY_FIELD_REASSIGNED', $logs[2]['code']); + static::assertSame('SWAG_MIGRATION_ENTITY_FIELD_REASSIGNED', $logs[3]['code']); } } diff --git a/tests/Profile/Magento2/Converter/Magento2CustomerGroupConverterTest.php b/tests/Profile/Magento2/Converter/Magento2CustomerGroupConverterTest.php index 1310f44a..3e376ae8 100644 --- a/tests/Profile/Magento2/Converter/Magento2CustomerGroupConverterTest.php +++ b/tests/Profile/Magento2/Converter/Magento2CustomerGroupConverterTest.php @@ -49,10 +49,11 @@ protected function setUp(): void $this->connection->setName('shopware'); $this->migrationContext = new MigrationContext( - new Magento23Profile(), $this->connection, - $this->runId, + new Magento23Profile(), + null, new CustomerGroupDataSet(), + $this->runId, 0, 250 ); diff --git a/tests/Profile/Magento2/Converter/Magento2LanguageConverterTest.php b/tests/Profile/Magento2/Converter/Magento2LanguageConverterTest.php index b6efedc4..01e34471 100644 --- a/tests/Profile/Magento2/Converter/Magento2LanguageConverterTest.php +++ b/tests/Profile/Magento2/Converter/Magento2LanguageConverterTest.php @@ -65,10 +65,11 @@ protected function setUp(): void $this->connection->setName('shopware'); $this->migrationContext = new MigrationContext( - new Magento23Profile(), $this->connection, - $this->runId, + new Magento23Profile(), + null, new LanguageDataSet(), + $this->runId, 0, 250 ); diff --git a/tests/Profile/Magento2/Converter/Magento2ManufacturerConverterTest.php b/tests/Profile/Magento2/Converter/Magento2ManufacturerConverterTest.php index 81a091e3..7e41a24d 100644 --- a/tests/Profile/Magento2/Converter/Magento2ManufacturerConverterTest.php +++ b/tests/Profile/Magento2/Converter/Magento2ManufacturerConverterTest.php @@ -55,10 +55,11 @@ protected function setUp(): void $this->connection->setName('shopware'); $this->migrationContext = new MigrationContext( - new Magento23Profile(), $this->connection, - $this->runId, + new Magento23Profile(), + null, new ManufacturerDataSet(), + $this->runId, 0, 250 ); diff --git a/tests/Profile/Magento2/Converter/Magento2MediaConverterTest.php b/tests/Profile/Magento2/Converter/Magento2MediaConverterTest.php index a46a96fc..0e4aeead 100644 --- a/tests/Profile/Magento2/Converter/Magento2MediaConverterTest.php +++ b/tests/Profile/Magento2/Converter/Magento2MediaConverterTest.php @@ -60,10 +60,11 @@ protected function setUp(): void $this->connection->setName('shopware'); $this->migrationContext = new MigrationContext( - new Magento23Profile(), $this->connection, - $this->runId, + new Magento23Profile(), + null, new MediaDataSet(), + $this->runId, 0, 250 ); diff --git a/tests/Profile/Magento2/Converter/Magento2NewsletterRecipientConverterTest.php b/tests/Profile/Magento2/Converter/Magento2NewsletterRecipientConverterTest.php index c5c39592..042429e8 100644 --- a/tests/Profile/Magento2/Converter/Magento2NewsletterRecipientConverterTest.php +++ b/tests/Profile/Magento2/Converter/Magento2NewsletterRecipientConverterTest.php @@ -92,10 +92,11 @@ protected function setUp(): void $this->newsletterRecipientConverter = new Magento23NewsletterRecipientConverter($this->mappingService, $this->loggingService); $this->migrationContext = new MigrationContext( - new Magento23Profile(), $this->connection, - $this->runId, + new Magento23Profile(), + null, new NewsletterRecipientDataSet(), + $this->runId, 0, 250 ); @@ -138,8 +139,7 @@ public function testConvertWithInvalidLanguage(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING_LANGUAGE'); - static::assertSame($newsletterRecipientData[0]['store_id'], $logs[0]['parameters']['sourceId']); + static::assertSame($logs[0]['code'], 'SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING'); } public function testConvertWithInvalidSalesChannel(): void @@ -165,8 +165,6 @@ public function testConvertWithInvalidSalesChannel(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_NEWSLETTER_RECIPIENT'); - static::assertSame($newsletterRecipientData[0]['subscriber_id'], $logs[0]['parameters']['sourceId']); - static::assertSame('salesChannel', $logs[0]['parameters']['emptyField']); + static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD'); } } diff --git a/tests/Profile/Magento2/Converter/Magento2OrderConverterTest.php b/tests/Profile/Magento2/Converter/Magento2OrderConverterTest.php index d8179a5a..7fdce351 100644 --- a/tests/Profile/Magento2/Converter/Magento2OrderConverterTest.php +++ b/tests/Profile/Magento2/Converter/Magento2OrderConverterTest.php @@ -93,10 +93,11 @@ protected function setUp(): void $this->connection->setName('shopware'); $this->migrationContext = new MigrationContext( - new Magento23Profile(), $this->connection, - $this->runId, + new Magento23Profile(), + null, new OrderDataSet(), + $this->runId, 0, 250 ); @@ -311,9 +312,7 @@ public function testConvertWithInvalidShippingMethod(): void static::assertArrayNotHasKey('deliveries', $convertResult->getConverted()); static::assertCount(1, $logs); - static::assertSame('SWAG_MIGRATION_SHIPPING_METHOD_ENTITY_UNKNOWN', $logs[0]['code']); - static::assertSame($orderData[0]['orders']['shipping_method'], $logs[0]['parameters']['sourceId']); - static::assertSame($orderData[0]['orders']['entity_id'], $logs[0]['parameters']['requiredForSourceId']); + static::assertSame('SWAG_MIGRATION_ENTITY_UNKNOWN', $logs[0]['code']); } public function testConvertWithoutOpenDeliveryStatusMapping(): void @@ -382,9 +381,7 @@ public function testConvertWithInvalidSalutation(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame('SWAG_MIGRATION_SALUTATION_ENTITY_UNKNOWN', $logs[0]['code']); - static::assertSame($order['orders']['customer_salutation'], $logs[0]['parameters']['sourceId']); - static::assertSame($order['orders']['entity_id'], $logs[0]['parameters']['requiredForSourceId']); + static::assertSame('SWAG_MIGRATION_ENTITY_UNKNOWN', $logs[0]['code']); $this->loggingService->resetLogging(); unset($order['orders']['customer_salutation']); @@ -396,9 +393,7 @@ public function testConvertWithInvalidSalutation(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame('SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_ORDER', $logs[0]['code']); - static::assertSame($order['orders']['entity_id'], $logs[0]['parameters']['sourceId']); - static::assertSame('salutation', $logs[0]['parameters']['emptyField']); + static::assertSame('SWAG_MIGRATION_EMPTY_NECESSARY_FIELD', $logs[0]['code']); } public function testConvertWithInvalidBillingAddress(): void @@ -422,13 +417,8 @@ public function testConvertWithInvalidBillingAddress(): void static::assertNotNull($convertResult->getUnmapped()); static::assertNull($convertResult->getConverted()); - static::assertSame('SWAG_MIGRATION_COUNTRY_ENTITY_UNKNOWN', $logs[0]['code']); - static::assertSame($order['billingAddress']['country_id'], $logs[0]['parameters']['sourceId']); - static::assertSame($order['orders']['entity_id'], $logs[0]['parameters']['requiredForSourceId']); - - static::assertSame('SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_ORDER', $logs[1]['code']); - static::assertSame($order['orders']['entity_id'], $logs[1]['parameters']['sourceId']); - static::assertSame('billingAddress', $logs[1]['parameters']['emptyField']); + static::assertSame('SWAG_MIGRATION_ENTITY_UNKNOWN', $logs[0]['code']); + static::assertSame('SWAG_MIGRATION_EMPTY_NECESSARY_FIELD', $logs[1]['code']); } public function testConvertAsGuestCustomer(): void @@ -480,13 +470,8 @@ public function testConvertAsGuestCustomerWithoutShippingAddress(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(2, $logs); - static::assertSame('SWAG_MIGRATION_COUNTRY_ENTITY_UNKNOWN', $logs[0]['code']); - static::assertSame($order['shippingAddress']['country_id'], $logs[0]['parameters']['sourceId']); - static::assertSame($order['orders']['entity_id'], $logs[0]['parameters']['requiredForSourceId']); - - static::assertSame('SWAG_MIGRATION_COUNTRY_ENTITY_UNKNOWN', $logs[1]['code']); - static::assertSame($order['shippingAddress']['country_id'], $logs[1]['parameters']['sourceId']); - static::assertSame($order['orders']['entity_id'], $logs[1]['parameters']['requiredForSourceId']); + static::assertSame('SWAG_MIGRATION_ENTITY_UNKNOWN', $logs[0]['code']); + static::assertSame('SWAG_MIGRATION_ENTITY_UNKNOWN', $logs[1]['code']); static::assertNull($convertResult->getUnmapped()); static::assertNotNull($convertResult->getConverted()); @@ -524,13 +509,8 @@ public function testConvertAsGuestCustomerWithInvalidBillingAddress(): void static::assertNotNull($convertResult->getUnmapped()); static::assertNull($convertResult->getConverted()); - static::assertSame('SWAG_MIGRATION_COUNTRY_ENTITY_UNKNOWN', $logs[0]['code']); - static::assertSame($order['billingAddress']['country_id'], $logs[0]['parameters']['sourceId']); - static::assertSame($order['orders']['entity_id'], $logs[0]['parameters']['requiredForSourceId']); - - static::assertSame('SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_ORDER', $logs[1]['code']); - static::assertSame($order['orders']['entity_id'], $logs[1]['parameters']['sourceId']); - static::assertSame('billingAddress', $logs[1]['parameters']['emptyField']); + static::assertSame('SWAG_MIGRATION_ENTITY_UNKNOWN', $logs[0]['code']); + static::assertSame('SWAG_MIGRATION_EMPTY_NECESSARY_FIELD', $logs[1]['code']); } public function testConvertAsGuestCustomerWithoutPaymentMethod(): void @@ -552,9 +532,7 @@ public function testConvertAsGuestCustomerWithoutPaymentMethod(): void static::assertNotNull($convertResult->getUnmapped()); static::assertNull($convertResult->getConverted()); - static::assertSame('SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_ORDER', $logs[0]['code']); - static::assertSame($order['orders']['entity_id'], $logs[0]['parameters']['sourceId']); - static::assertSame('payment_method', $logs[0]['parameters']['emptyField']); + static::assertSame('SWAG_MIGRATION_EMPTY_NECESSARY_FIELD', $logs[0]['code']); } public function testConvertAsGuestCustomerWithWithInvalidLanguage(): void @@ -576,9 +554,7 @@ public function testConvertAsGuestCustomerWithWithInvalidLanguage(): void static::assertNotNull($convertResult->getUnmapped()); static::assertNull($convertResult->getConverted()); - static::assertSame('SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_ORDER', $logs[0]['code']); - static::assertSame($order['orders']['entity_id'], $logs[0]['parameters']['sourceId']); - static::assertSame('language', $logs[0]['parameters']['emptyField']); + static::assertSame('SWAG_MIGRATION_EMPTY_NECESSARY_FIELD', $logs[0]['code']); } public function testConvertAsGuestCustomerWithWithInvalidCustomerGroup(): void @@ -600,9 +576,7 @@ public function testConvertAsGuestCustomerWithWithInvalidCustomerGroup(): void static::assertNotNull($convertResult->getUnmapped()); static::assertNull($convertResult->getConverted()); - static::assertSame('SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_ORDER', $logs[0]['code']); - static::assertSame($order['orders']['entity_id'], $logs[0]['parameters']['sourceId']); - static::assertSame('customer_group_id', $logs[0]['parameters']['emptyField']); + static::assertSame('SWAG_MIGRATION_EMPTY_NECESSARY_FIELD', $logs[0]['code']); } public function testConvertWithoutSalutation(): void @@ -637,9 +611,7 @@ public function testConvertWithInvalidCurrency(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_ORDER'); - static::assertSame($logs[0]['parameters']['sourceId'], $order['orders']['entity_id']); - static::assertSame($logs[0]['parameters']['emptyField'], 'currency'); + static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD'); } public function testConvertWithInvalidOrderState(): void @@ -657,26 +629,25 @@ public function testConvertWithInvalidOrderState(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_ORDER_STATE_ENTITY_UNKNOWN'); - static::assertSame($logs[0]['parameters']['sourceId'], $order['orders']['status']); + static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_ENTITY_UNKNOWN'); } public static function requiredProperties(): array { return [ - ['orders', null], - ['orders', ''], - ['billingAddress', null], - ['billingAddress', ''], - ['shippingAddress', null], - ['shippingAddress', ''], - ['items', null], - ['items', ''], + ['orders', 2, null], + ['orders', 2, ''], + ['billingAddress', 1, null], + ['billingAddress', 1, ''], + ['shippingAddress', 1, null], + ['shippingAddress', 1, ''], + ['items', 1, null], + ['items', 1, ''], ]; } #[DataProvider('requiredProperties')] - public function testConvertWithoutRequiredProperties(string $property, ?string $value): void + public function testConvertWithoutRequiredProperties(string $property, int $expected, ?string $value): void { $orderData = require __DIR__ . '/../../../_fixtures/order_data.php'; $orderData = $orderData[0]; @@ -687,14 +658,6 @@ public function testConvertWithoutRequiredProperties(string $property, ?string $ static::assertNull($convertResult->getConverted()); $logs = $this->loggingService->getLoggingArray(); - static::assertCount(1, $logs); - - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_ORDER'); - - if ($property === 'orders') { - static::assertSame($logs[0]['parameters']['emptyField'], 'orders,entity_id'); - } else { - static::assertSame($logs[0]['parameters']['emptyField'], $property); - } + static::assertCount($expected, $logs); } } diff --git a/tests/Profile/Magento2/Converter/Magento2ProductChildMultiSelectPropertyRelationConverterTest.php b/tests/Profile/Magento2/Converter/Magento2ProductChildMultiSelectPropertyRelationConverterTest.php index e528cb06..95015114 100644 --- a/tests/Profile/Magento2/Converter/Magento2ProductChildMultiSelectPropertyRelationConverterTest.php +++ b/tests/Profile/Magento2/Converter/Magento2ProductChildMultiSelectPropertyRelationConverterTest.php @@ -51,10 +51,11 @@ protected function setUp(): void $this->connection->setName('shopware'); $this->migrationContext = new MigrationContext( - new Magento23Profile(), $this->connection, - $this->runId, + new Magento23Profile(), + null, new ProductChildMultiSelectPropertyRelationDataSet(), + $this->runId, 0, 250 ); diff --git a/tests/Profile/Magento2/Converter/Magento2ProductChildPropertyRelationTest.php b/tests/Profile/Magento2/Converter/Magento2ProductChildPropertyRelationTest.php index bf073fed..f6e3b4a1 100644 --- a/tests/Profile/Magento2/Converter/Magento2ProductChildPropertyRelationTest.php +++ b/tests/Profile/Magento2/Converter/Magento2ProductChildPropertyRelationTest.php @@ -51,10 +51,11 @@ protected function setUp(): void $this->connection->setName('shopware'); $this->migrationContext = new MigrationContext( - new Magento23Profile(), $this->connection, - $this->runId, + new Magento23Profile(), + null, new ProductChildPropertyRelationDataSet(), + $this->runId, 0, 250 ); diff --git a/tests/Profile/Magento2/Converter/Magento2ProductConverterTest.php b/tests/Profile/Magento2/Converter/Magento2ProductConverterTest.php index 9bda8343..b07a04c7 100644 --- a/tests/Profile/Magento2/Converter/Magento2ProductConverterTest.php +++ b/tests/Profile/Magento2/Converter/Magento2ProductConverterTest.php @@ -67,10 +67,11 @@ protected function setUp(): void $this->connection->setName('shopware'); $this->migrationContext = new MigrationContext( - new Magento23Profile(), $this->connection, - $this->runId, + new Magento23Profile(), + null, new ProductDataSet(), + $this->runId, 0, 250 ); @@ -255,9 +256,7 @@ public function testConvertWithoutTax(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_PRODUCT'); - static::assertSame($logs[0]['parameters']['sourceId'], $product['entity_id']); - static::assertSame($logs[0]['parameters']['emptyField'], 'tax class'); + static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD'); } public function testConvertWithInvalidTax(): void @@ -275,8 +274,7 @@ public function testConvertWithInvalidTax(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_TAX_ENTITY_UNKNOWN'); - static::assertSame($logs[0]['parameters']['sourceId'], $product['tax_class_id']); + static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_ENTITY_UNKNOWN'); } public function testConvertSimpleProductWithoutPrice(): void @@ -295,9 +293,7 @@ public function testConvertSimpleProductWithoutPrice(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_PRODUCT'); - static::assertSame($logs[0]['parameters']['sourceId'], $product['entity_id']); - static::assertSame($logs[0]['parameters']['emptyField'], 'price'); + static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD'); } public function testConvertConfigurableProductWithoutPrice(): void @@ -331,9 +327,7 @@ public function testConvertWithoutDefaultCurrency(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_PRODUCT'); - static::assertSame($logs[0]['parameters']['sourceId'], $product['entity_id']); - static::assertSame($logs[0]['parameters']['emptyField'], 'currency'); + static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD'); } public function testConvertWithPriceIsGross(): void diff --git a/tests/Profile/Magento2/Converter/Magento2ProductCustomFieldConverterTest.php b/tests/Profile/Magento2/Converter/Magento2ProductCustomFieldConverterTest.php index bad2d4a7..ab2f5c09 100644 --- a/tests/Profile/Magento2/Converter/Magento2ProductCustomFieldConverterTest.php +++ b/tests/Profile/Magento2/Converter/Magento2ProductCustomFieldConverterTest.php @@ -49,10 +49,11 @@ protected function setUp(): void $this->connection->setName('shopware'); $this->migrationContext = new MigrationContext( - new Magento23Profile(), $this->connection, - $this->runId, + new Magento23Profile(), + null, new ProductCustomFieldDataSet(), + $this->runId, 0, 250 ); diff --git a/tests/Profile/Magento2/Converter/Magento2ProductMultiSelectPropertyRelationConverterTest.php b/tests/Profile/Magento2/Converter/Magento2ProductMultiSelectPropertyRelationConverterTest.php index 355ea45b..79edfadc 100644 --- a/tests/Profile/Magento2/Converter/Magento2ProductMultiSelectPropertyRelationConverterTest.php +++ b/tests/Profile/Magento2/Converter/Magento2ProductMultiSelectPropertyRelationConverterTest.php @@ -51,10 +51,11 @@ protected function setUp(): void $this->connection->setName('shopware'); $this->migrationContext = new MigrationContext( - new Magento23Profile(), $this->connection, - $this->runId, + new Magento23Profile(), + null, new ProductMultiSelectPropertyRelationDataSet(), + $this->runId, 0, 250 ); diff --git a/tests/Profile/Magento2/Converter/Magento2ProductOptionRelationConvertTest.php b/tests/Profile/Magento2/Converter/Magento2ProductOptionRelationConvertTest.php index cc8bd6dd..6282d61b 100644 --- a/tests/Profile/Magento2/Converter/Magento2ProductOptionRelationConvertTest.php +++ b/tests/Profile/Magento2/Converter/Magento2ProductOptionRelationConvertTest.php @@ -51,10 +51,11 @@ protected function setUp(): void $this->connection->setName('shopware'); $this->migrationContext = new MigrationContext( - new Magento23Profile(), $this->connection, - $this->runId, + new Magento23Profile(), + null, new ProductOptionRelationDataSet(), + $this->runId, 0, 250 ); diff --git a/tests/Profile/Magento2/Converter/Magento2ProductPropertyRelationConvertTest.php b/tests/Profile/Magento2/Converter/Magento2ProductPropertyRelationConvertTest.php index 43dd3e11..bc085129 100644 --- a/tests/Profile/Magento2/Converter/Magento2ProductPropertyRelationConvertTest.php +++ b/tests/Profile/Magento2/Converter/Magento2ProductPropertyRelationConvertTest.php @@ -51,10 +51,11 @@ protected function setUp(): void $this->connection->setName('shopware'); $this->migrationContext = new MigrationContext( - new Magento23Profile(), $this->connection, - $this->runId, + new Magento23Profile(), + null, new ProductPropertyRelationDataSet(), + $this->runId, 0, 250 ); diff --git a/tests/Profile/Magento2/Converter/Magento2ProductReviewConverterTest.php b/tests/Profile/Magento2/Converter/Magento2ProductReviewConverterTest.php index 7cce4e08..d636a24d 100644 --- a/tests/Profile/Magento2/Converter/Magento2ProductReviewConverterTest.php +++ b/tests/Profile/Magento2/Converter/Magento2ProductReviewConverterTest.php @@ -53,10 +53,11 @@ protected function setUp(): void $this->connection->setName('shopware'); $this->migrationContext = new MigrationContext( - new Magento23Profile(), $this->connection, - $this->runId, + new Magento23Profile(), + null, new ProductReviewDataSet(), + $this->runId, 0, 250 ); @@ -140,8 +141,7 @@ public function testConvertWithoutProductMapping(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING_PRODUCT'); - static::assertSame($logs[0]['parameters']['sourceId'], $productReviewData[0]['productId']); + static::assertSame($logs[0]['code'], 'SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING'); } public function testConvertWithoutCustomerMapping(): void @@ -174,8 +174,7 @@ public function testConvertWithoutSalesChannelMapping(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING_SALES_CHANNEL'); - static::assertSame($logs[0]['parameters']['sourceId'], $productReviewData[0]['store_id']); + static::assertSame($logs[0]['code'], 'SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING'); } public function testConvertWithoutLanguageMapping(): void @@ -193,7 +192,6 @@ public function testConvertWithoutLanguageMapping(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING_STORE_LANGUAGE'); - static::assertSame($logs[0]['parameters']['sourceId'], $productReviewData[0]['store_id']); + static::assertSame($logs[0]['code'], 'SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING'); } } diff --git a/tests/Profile/Magento2/Converter/Magento2PropertyGroupConverterTest.php b/tests/Profile/Magento2/Converter/Magento2PropertyGroupConverterTest.php index 2a871941..499b4bd6 100644 --- a/tests/Profile/Magento2/Converter/Magento2PropertyGroupConverterTest.php +++ b/tests/Profile/Magento2/Converter/Magento2PropertyGroupConverterTest.php @@ -71,10 +71,11 @@ protected function setUp(): void ); $this->migrationContext = new MigrationContext( - new Magento23Profile(), $this->connection, - $this->runId, + new Magento23Profile(), + null, new PropertyGroupDataSet(), + $this->runId, 0, 250 ); @@ -127,8 +128,6 @@ public function testConvertWithoutName(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_PROPERTY_GROUP'); - static::assertSame($logs[0]['parameters']['sourceId'], $propertyGroupData[0]['id']); - static::assertSame($logs[0]['parameters']['emptyField'], 'group name'); + static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD'); } } diff --git a/tests/Profile/Magento2/Converter/Magento2SalesChannelConverterTest.php b/tests/Profile/Magento2/Converter/Magento2SalesChannelConverterTest.php index ce51db03..6f004853 100644 --- a/tests/Profile/Magento2/Converter/Magento2SalesChannelConverterTest.php +++ b/tests/Profile/Magento2/Converter/Magento2SalesChannelConverterTest.php @@ -70,10 +70,11 @@ protected function setUp(): void $this->connection->setName('shopware'); $this->migrationContext = new MigrationContext( - new Magento23Profile(), $this->connection, - $this->runId, + new Magento23Profile(), + null, new SalesChannelDataSet(), + $this->runId, 0, 250 ); @@ -139,8 +140,7 @@ public function testConvertWithoutDefaultLanguage(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING_LANGUAGE'); - static::assertSame($logs[0]['parameters']['sourceId'], 'default_locale'); + static::assertSame($logs[0]['code'], 'SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING'); } public function testConvertWithoutDefaultCurrency(): void @@ -157,8 +157,7 @@ public function testConvertWithoutDefaultCurrency(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING_CURRENCY'); - static::assertSame($logs[0]['parameters']['sourceId'], 'default_currency'); + static::assertSame($logs[0]['code'], 'SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING'); } public function testConvertWithoutDefaultCategory(): void @@ -176,8 +175,7 @@ public function testConvertWithoutDefaultCategory(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING_CATEGORY'); - static::assertSame($logs[0]['parameters']['sourceId'], $salesChannelData[0]['root_category_id']); + static::assertSame($logs[0]['code'], 'SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING'); } public function testConvertMissingPaymentMethod(): void @@ -200,8 +198,7 @@ public function testConvertMissingPaymentMethod(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING_PAYMENT_METHOD'); - static::assertSame($logs[0]['parameters']['sourceId'], 'cashondelivery'); + static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD'); } public function testConvertMissingShippingMethod(): void @@ -224,8 +221,7 @@ public function testConvertMissingShippingMethod(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING_SHIPPING_METHOD'); - static::assertSame($logs[0]['parameters']['sourceId'], 'ups'); + static::assertSame($logs[0]['code'], 'SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING'); } public function testConvertMissingWithoutPaymentMethods(): void diff --git a/tests/Profile/Magento2/Converter/Magento2SeoUrlConverterTest.php b/tests/Profile/Magento2/Converter/Magento2SeoUrlConverterTest.php index b63f03db..0e872c95 100644 --- a/tests/Profile/Magento2/Converter/Magento2SeoUrlConverterTest.php +++ b/tests/Profile/Magento2/Converter/Magento2SeoUrlConverterTest.php @@ -62,10 +62,11 @@ protected function setUp(): void $this->connection->setName('shopware'); $this->migrationContext = new MigrationContext( - new Magento23Profile(), $this->connection, - $this->runId, + new Magento23Profile(), + null, new SeoUrlDataSet(), + $this->runId, 0, 250 ); @@ -100,8 +101,7 @@ public function testConvertWithInvalidSalesChannel(): void static::assertNotNull($convertResult->getUnmapped()); static::assertNull($converted); static::assertCount(1, $logs); - static::assertSame('SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING_SALES_CHANNEL', $logs[0]['code']); - static::assertSame($seoUrlData[0]['store_id'], $logs[0]['parameters']['sourceId']); + static::assertSame('SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING', $logs[0]['code']); } public function testConvertWithInvalidLanguage(): void @@ -115,8 +115,7 @@ public function testConvertWithInvalidLanguage(): void static::assertNotNull($convertResult->getUnmapped()); static::assertNull($converted); static::assertCount(1, $logs); - static::assertSame('SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING_STORE_LANGUAGE', $logs[0]['code']); - static::assertSame($seoUrlData[0]['store_id'], $logs[0]['parameters']['sourceId']); + static::assertSame('SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING', $logs[0]['code']); } public function testConvertWithInvalidProduct(): void @@ -130,8 +129,7 @@ public function testConvertWithInvalidProduct(): void static::assertNotNull($convertResult->getUnmapped()); static::assertNull($converted); static::assertCount(1, $logs); - static::assertSame('SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING_PRODUCT', $logs[0]['code']); - static::assertSame($seoUrlData[0]['product_id'], $logs[0]['parameters']['sourceId']); + static::assertSame('SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING', $logs[0]['code']); } public function testConvertWithInvalidCategory(): void @@ -145,8 +143,7 @@ public function testConvertWithInvalidCategory(): void static::assertNotNull($convertResult->getUnmapped()); static::assertNull($converted); static::assertCount(1, $logs); - static::assertSame('SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING_CATEGORY', $logs[0]['code']); - static::assertSame($seoUrlData[0]['category_id'], $logs[0]['parameters']['sourceId']); + static::assertSame('SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING', $logs[0]['code']); } public function testConvertWithoutProductOrCategory(): void @@ -160,9 +157,7 @@ public function testConvertWithoutProductOrCategory(): void static::assertNotNull($convertResult->getUnmapped()); static::assertNull($converted); static::assertCount(1, $logs); - static::assertSame('SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_SEO_URL', $logs[0]['code']); - static::assertSame($seoUrlData[2]['url_rewrite_id'], $logs[0]['parameters']['sourceId']); - static::assertSame('category_id, product_id', $logs[0]['parameters']['emptyField']); + static::assertSame('SWAG_MIGRATION_EMPTY_NECESSARY_FIELD', $logs[0]['code']); } public function testConvertProductAndCategorySeoUrl(): void