Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/Profile/Shopware/Converter/CategoryConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,11 @@ public function convert(
$this->connectionName = $connection->getName();

if (!isset($data['_locale'])) {
$this->loggingService->addLogEntry( // TODO: add optional fields
$this->loggingService->addLogEntry(
SwagMigrationLogBuilder::fromMigrationContext($migrationContext)
->withEntityName(CategoryDefinition::ENTITY_NAME)
->withFieldSourcePath('_locale')
->withSourceData($data)
->build(EmptyNecessaryFieldRunLog::class)
);

Expand Down
15 changes: 13 additions & 2 deletions src/Profile/Shopware/Converter/CrossSellingConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace SwagMigrationAssistant\Profile\Shopware\Converter;

use Shopware\Core\Content\Product\Aggregate\ProductCrossSelling\ProductCrossSellingDefinition;
use Shopware\Core\Framework\Context;
use Shopware\Core\Framework\Log\Package;
use SwagMigrationAssistant\Migration\Converter\ConvertStruct;
Expand Down Expand Up @@ -59,8 +60,13 @@ public function convert(array $data, Context $context, MigrationContextInterface

$sourceProductMapping = $this->getProductMapping($data['articleID']);
if ($sourceProductMapping === null) {
$this->loggingService->addLogEntry( // TODO: add optional fields
$this->loggingService->addLogEntry(
SwagMigrationLogBuilder::fromMigrationContext($migrationContext)
->withEntityName(ProductCrossSellingDefinition::ENTITY_NAME)
->withFieldName('id')
->withFieldSourcePath('articleID')
->withSourceData($data)
->withConvertedData($converted)
->build(AssociationRequiredMissingLog::class)
);

Expand All @@ -70,8 +76,13 @@ public function convert(array $data, Context $context, MigrationContextInterface

$relatedProductMapping = $this->getProductMapping($data['relatedarticle']);
if ($relatedProductMapping === null) {
$this->loggingService->addLogEntry( // TODO: add optional fields
$this->loggingService->addLogEntry(
SwagMigrationLogBuilder::fromMigrationContext($migrationContext)
->withEntityName(ProductCrossSellingDefinition::ENTITY_NAME)
->withFieldName('id')
->withFieldSourcePath('relatedarticle')
->withSourceData($data)
->withConvertedData($converted)
->build(AssociationRequiredMissingLog::class)
);

Expand Down
102 changes: 86 additions & 16 deletions src/Profile/Shopware/Converter/CustomerConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

namespace SwagMigrationAssistant\Profile\Shopware\Converter;

use Shopware\Core\Checkout\Customer\Aggregate\CustomerAddress\CustomerAddressDefinition;
use Shopware\Core\Checkout\Customer\CustomerDefinition;
use Shopware\Core\Defaults;
use Shopware\Core\Framework\Context;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
Expand Down Expand Up @@ -107,17 +109,25 @@ public function convert(
$fields = $this->checkForEmptyRequiredDataFields($data, $this->requiredDataFieldKeys);

if (!empty($fields)) {
$this->loggingService->addLogEntry( // TODO: add optional fields
SwagMigrationLogBuilder::fromMigrationContext($migrationContext)
$this->loggingService->addLogForEach(
$fields,
fn (string $key) => SwagMigrationLogBuilder::fromMigrationContext($migrationContext)
->withEntityName(CustomerDefinition::ENTITY_NAME)
->withFieldSourcePath($key)
->withSourceData($data)
->build(EmptyNecessaryFieldRunLog::class)
);

return new ConvertStruct(null, $oldData);
}

if (!$this->checkEmailValidity($data['email'])) {
$this->loggingService->addLogEntry( // TODO: add optional fields
$this->loggingService->addLogEntry(
SwagMigrationLogBuilder::fromMigrationContext($migrationContext)
->withEntityName(CustomerDefinition::ENTITY_NAME)
->withFieldName('email')
->withFieldSourcePath('email')
->withSourceData($data)
->build(InvalidEmailAddressLog::class)
);

Expand Down Expand Up @@ -227,8 +237,13 @@ public function convert(
);

if ($mapping === null) {
$this->loggingService->addLogEntry( // TODO: add optional fields
$this->loggingService->addLogEntry(
SwagMigrationLogBuilder::fromMigrationContext($migrationContext)
->withEntityName(CustomerDefinition::ENTITY_NAME)
->withFieldName('defaultPaymentMethodId')
->withFieldSourcePath('default_payment_method')
->withSourceData($data)
->withConvertedData($converted)
->build(EmptyNecessaryFieldRunLog::class)
);

Expand Down Expand Up @@ -284,11 +299,30 @@ public function convert(
$returnData = null;
}

if (!isset($converted['defaultBillingAddressId'], $converted['defaultShippingAddressId'])) {
if (!isset($converted['defaultBillingAddressId'])) {
$this->mappingService->deleteMapping($converted['id'], $this->connectionId, $this->context);

$this->loggingService->addLogEntry( // TODO: add optional fields
$this->loggingService->addLogEntry(
SwagMigrationLogBuilder::fromMigrationContext($migrationContext)
->withEntityName(CustomerDefinition::ENTITY_NAME)
->withFieldName('defaultBillingAddressId')
->withFieldSourcePath('default_billing_address_id')
->withSourceData($data)
->build(EmptyNecessaryFieldRunLog::class)
);

return new ConvertStruct(null, $oldData);
}

if (!isset($converted['defaultShippingAddressId'])) {
$this->mappingService->deleteMapping($converted['id'], $this->connectionId, $this->context);

$this->loggingService->addLogEntry(
SwagMigrationLogBuilder::fromMigrationContext($migrationContext)
->withEntityName(CustomerDefinition::ENTITY_NAME)
->withFieldName('defaultShippingAddressId')
->withFieldSourcePath('default_shipping_address_id')
->withSourceData($data)
->build(EmptyNecessaryFieldRunLog::class)
);

Expand Down Expand Up @@ -332,8 +366,12 @@ protected function getDefaultPaymentMethod(array $originalData): ?string
);

if ($paymentMethodMapping === null) {
$this->loggingService->addLogEntry( // TODO: add optional fields
$this->loggingService->addLogEntry(
SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext)
->withEntityName(CustomerDefinition::ENTITY_NAME)
->withFieldName('defaultPaymentMethodId')
->withFieldSourcePath('default_payment_method')
->withSourceData($originalData)
->build(UnknownEntityLog::class)
);

Expand All @@ -357,8 +395,12 @@ protected function applyAddresses(array &$originalData, array &$converted, strin

$fields = $this->checkForEmptyRequiredDataFields($address, $this->requiredAddressDataFieldKeys);
if (!empty($fields)) {
$this->loggingService->addLogEntry( // TODO: add optional fields
SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext)
$this->loggingService->addLogForEach(
$fields,
fn (string $key) => SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext)
->withEntityName(CustomerAddressDefinition::ENTITY_NAME)
->withFieldSourcePath($key)
->withSourceData($address)
->build(EmptyNecessaryFieldRunLog::class)
);

Expand Down Expand Up @@ -539,8 +581,12 @@ protected function getCountryState(array $oldAddressData, string $newCountryId):
$state = ['countryId' => $newCountryId];

if (!isset($oldAddressData['state_id'], $oldAddressData['country']['countryiso'], $oldAddressData['state']['shortcode'])) {
$this->loggingService->addLogEntry( // TODO: add optional fields
$this->loggingService->addLogEntry(
SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext)
->withEntityName(CustomerAddressDefinition::ENTITY_NAME)
->withFieldName('stateId')
->withFieldSourcePath('state_id')
->withSourceData($oldAddressData)
->build(UnknownEntityLog::class)
);

Expand Down Expand Up @@ -572,8 +618,12 @@ protected function getCountryState(array $oldAddressData, string $newCountryId):
$oldAddressData['state']['position'],
$oldAddressData['state']['active']
)) {
$this->loggingService->addLogEntry( // TODO: add optional fields
$this->loggingService->addLogEntry(
SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext)
->withEntityName(CustomerAddressDefinition::ENTITY_NAME)
->withFieldName('stateId')
->withFieldSourcePath('state.name')
->withSourceData($oldAddressData['state'])
->build(UnknownEntityLog::class)
);

Expand Down Expand Up @@ -643,8 +693,16 @@ protected function checkUnsetDefaultShippingAndDefaultBillingAddress(array &$ori
$converted['defaultShippingAddressId'] = $addresses[0]['id'];
unset($originalData['default_billing_address_id'], $originalData['default_shipping_address_id']);

$this->loggingService->addLogEntry( // TODO: add optional fields
SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext)
$this->loggingService->addLogForEach(
[
'defaultBillingAddressId' => 'default_billing_address_id',
'defaultShippingAddressId' => 'default_shipping_address_id',
],
fn (string $key, string $value) => SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext)
->withEntityName(CustomerAddressDefinition::ENTITY_NAME)
->withFieldName($key)
->withFieldSourcePath($value)
->withSourceData($originalData)
->build(FieldReassignedRunLog::class)
);
}
Expand All @@ -660,8 +718,12 @@ protected function checkUnsetDefaultShippingAddress(array &$originalData, array
$converted['defaultShippingAddressId'] = $converted['defaultBillingAddressId'];
unset($originalData['default_shipping_address_id']);

$this->loggingService->addLogEntry( // TODO: add optional fields
$this->loggingService->addLogEntry(
SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext)
->withEntityName(CustomerAddressDefinition::ENTITY_NAME)
->withFieldName('defaultShippingAddressId')
->withFieldSourcePath('default_shipping_address_id')
->withSourceData($originalData)
->build(FieldReassignedRunLog::class)
);
}
Expand All @@ -677,8 +739,12 @@ protected function checkUnsetDefaultBillingAddress(array &$originalData, array &
$converted['defaultBillingAddressId'] = $converted['defaultShippingAddressId'];
unset($originalData['default_billing_address_id']);

$this->loggingService->addLogEntry( // TODO: add optional fields
$this->loggingService->addLogEntry(
SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext)
->withEntityName(CustomerAddressDefinition::ENTITY_NAME)
->withFieldName('defaultBillingAddressId')
->withFieldSourcePath('default_billing_address_id')
->withSourceData($originalData)
->build(FieldReassignedRunLog::class)
);
}
Expand All @@ -694,8 +760,12 @@ protected function getSalutation(string $salutation): ?string
);

if ($mapping === null) {
$this->loggingService->addLogEntry( // TODO: add optional fields
$this->loggingService->addLogEntry(
SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext)
->withEntityName(CustomerDefinition::ENTITY_NAME)
->withFieldName('salutationId')
->withFieldSourcePath('salutation')
->withSourceData(['salutation' => $salutation])
->build(UnknownEntityLog::class)
);

Expand Down
6 changes: 5 additions & 1 deletion src/Profile/Shopware/Converter/LanguageConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

use Shopware\Core\Framework\Context;
use Shopware\Core\Framework\Log\Package;
use Shopware\Core\System\Language\LanguageDefinition;
use SwagMigrationAssistant\Migration\Converter\ConvertStruct;
use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities;
use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder;
Expand Down Expand Up @@ -50,8 +51,11 @@ public function convert(array $data, Context $context, MigrationContextInterface

$languageUuid = $this->languageLookup->get($data['locale'], $context);
if ($languageUuid !== null) {
$this->loggingService->addLogEntry( // TODO: add optional fields
$this->loggingService->addLogEntry(
SwagMigrationLogBuilder::fromMigrationContext($migrationContext)
->withEntityName(LanguageDefinition::ENTITY_NAME)
->withFieldSourcePath('locale')
->withSourceData($data)
->build(EntityAlreadyExistsRunLog::class)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,11 @@ public function convert(array $data, Context $context, MigrationContextInterface
*/
private function addAssociationRequiredLog(MigrationContextInterface $migrationContext, string $field, string $entity, array $data): void
{
$this->loggingService->addLogEntry( // TODO: add optional fields
$this->loggingService->addLogEntry(
SwagMigrationLogBuilder::fromMigrationContext($migrationContext)
->withEntityName($entity)
->withFieldName($field)
->withFieldSourcePath($field)
->withSourceData([$data])
->withSourceData($data)
->build(AssociationRequiredMissingLog::class)
);
}
Expand Down
16 changes: 13 additions & 3 deletions src/Profile/Shopware/Converter/NewsletterRecipientConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,11 @@ protected function getSalutation(string $salutation, MigrationContextInterface $
);

if ($salutationMapping === null) {
$this->loggingService->addLogEntry( // TODO: add optional fields
$this->loggingService->addLogEntry(
SwagMigrationLogBuilder::fromMigrationContext($migrationContext)
->withEntityName(NewsletterRecipientDefinition::ENTITY_NAME)
->withFieldName('salutationId')
->withSourceData(['salutation' => $salutation])
->build(UnknownEntityLog::class)
);

Expand All @@ -188,8 +191,12 @@ protected function getSalesChannel(array $data): ?string
}

if (!isset($salesChannelMapping)) {
$this->loggingService->addLogEntry( // TODO: add optional fields
$this->loggingService->addLogEntry(
SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext)
->withEntityName(NewsletterRecipientDefinition::ENTITY_NAME)
->withFieldName('salesChannelId')
->withFieldSourcePath('shopId')
->withSourceData($data)
->build(EmptyNecessaryFieldRunLog::class)
);

Expand All @@ -210,8 +217,11 @@ protected function getStatus(MigrationContextInterface $migrationContext): ?stri
);

if ($status === null) {
$this->loggingService->addLogEntry( // TODO: add optional fields
$this->loggingService->addLogEntry(
SwagMigrationLogBuilder::fromMigrationContext($migrationContext)
->withEntityName(NewsletterRecipientDefinition::ENTITY_NAME)
->withFieldName('status')
->withSourceData(['status' => NewsletterRecipientStatusReader::SOURCE_ID])
->build(EmptyNecessaryFieldRunLog::class)
);
}
Expand Down
13 changes: 11 additions & 2 deletions src/Profile/Shopware/Converter/NumberRangeConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Shopware\Core\Framework\Log\Package;
use Shopware\Core\Framework\Uuid\Uuid;
use Shopware\Core\System\NumberRange\NumberRangeCollection;
use Shopware\Core\System\NumberRange\NumberRangeDefinition;
use Shopware\Core\System\NumberRange\NumberRangeEntity;
use SwagMigrationAssistant\Migration\Converter\ConvertStruct;
use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities;
Expand Down Expand Up @@ -72,8 +73,12 @@ public function convert(array $data, Context $context, MigrationContextInterface
$this->connectionId = $connection->getId();

if (!\array_key_exists($data['name'], self::TYPE_MAPPING)) {
$this->loggingService->addLogEntry( // TODO: add optional fields
$this->loggingService->addLogEntry(
SwagMigrationLogBuilder::fromMigrationContext($migrationContext)
->withEntityName(NumberRangeDefinition::ENTITY_NAME)
->withFieldName('typeId')
->withFieldSourcePath('name')
->withSourceData($data)
->build(UnsupportedNumberRangeTypeLog::class)
);

Expand All @@ -85,8 +90,12 @@ public function convert(array $data, Context $context, MigrationContextInterface
$converted['typeId'] = $this->getProductNumberRangeTypeUuid($data['name']);

if (empty($converted['typeId'])) {
$this->loggingService->addLogEntry( // TODO: add optional fields
$this->loggingService->addLogEntry(
SwagMigrationLogBuilder::fromMigrationContext($migrationContext)
->withEntityName(NumberRangeDefinition::ENTITY_NAME)
->withFieldName('typeId')
->withFieldSourcePath('name')
->withSourceData($data)
->build(EmptyNecessaryFieldRunLog::class)
);

Expand Down
Loading