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
12 changes: 9 additions & 3 deletions src/Profile/Magento/Converter/CategoryConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -100,12 +101,17 @@ 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( // TODO: add optional fields
SwagMigrationLogBuilder::fromMigrationContext($migrationContext)
$this->loggingService->addLogForEach(
$fields,
fn (string $key) => SwagMigrationLogBuilder::fromMigrationContext($migrationContext)
->withEntityName(CategoryDefinition::ENTITY_NAME)
->withFieldSourcePath($key)
->withSourceData($data)
->build(EmptyNecessaryFieldRunLog::class)
);

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

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;
Expand Down Expand Up @@ -61,8 +62,13 @@ public function convert(array $data, Context $context, MigrationContextInterface
);

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

Expand All @@ -78,8 +84,13 @@ public function convert(array $data, Context $context, MigrationContextInterface
);

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

Expand Down
8 changes: 6 additions & 2 deletions src/Profile/Magento/Converter/CustomFieldConverter.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\CustomField\CustomFieldDefinition;
use SwagMigrationAssistant\Migration\Converter\Converter;
use SwagMigrationAssistant\Migration\Converter\ConvertStruct;
use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities;
Expand Down Expand Up @@ -63,9 +64,12 @@ public function convert(array $data, Context $context, MigrationContextInterface
);

if ($defaultLocale === null) {
$this->loggingService->addLogEntry( // TODO: add optional fields
$this->loggingService->addLogEntry(
SwagMigrationLogBuilder::fromMigrationContext($migrationContext)
->withEntityName(DefaultEntities::CUSTOM_FIELD_SET)
->withEntityName(CustomFieldDefinition::ENTITY_NAME)
->withFieldName('locale')
->withFieldSourcePath('global_default')
->withSourceData($data)
->build(AssociationRequiredMissingLog::class)
);

Expand Down
99 changes: 82 additions & 17 deletions src/Profile/Magento/Converter/CustomerConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -89,9 +91,14 @@ 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( // 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)
);

Expand Down Expand Up @@ -149,8 +156,13 @@ public function convert(array $data, Context $context, MigrationContextInterface
}

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

Expand Down Expand Up @@ -191,8 +203,13 @@ public function convert(array $data, Context $context, MigrationContextInterface
);

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

Expand Down Expand Up @@ -243,8 +260,13 @@ 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( // TODO: add optional fields
SwagMigrationLogBuilder::fromMigrationContext($migrationContext)
$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)
);

Expand Down Expand Up @@ -287,11 +309,16 @@ 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( // TODO: add optional fields
SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext)
$this->loggingService->addLogForEach(
$fields,
fn (string $key) => SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext)
->withEntityName(CustomerDefinition::ENTITY_NAME)
->withFieldSourcePath($key)
->withSourceData($address)
->withConvertedData($converted)
->build(EmptyNecessaryFieldRunLog::class)
);

Expand Down Expand Up @@ -321,9 +348,14 @@ 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( // TODO: add optional fields
$this->loggingService->addLogEntry(
SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext)
->withEntityName(CustomerAddressDefinition::ENTITY_NAME)
->withFieldName('countryId')
->withFieldSourcePath('country_iso3')
->withSourceData($addresses)
->build(UnknownEntityLog::class)
);

Expand Down Expand Up @@ -357,8 +389,13 @@ protected function getAddresses(array &$originalData, array &$converted, string
'countryId' => $countryUuid,
];
} else {
$this->loggingService->addLogEntry( // TODO: add optional fields
$this->loggingService->addLogEntry(
SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext)
->withEntityName(CustomerAddressDefinition::ENTITY_NAME)
->withFieldName('countryState')
->withFieldSourcePath('region')
->withSourceData($originalData)
->withConvertedData($converted)
->build(UnknownEntityLog::class)
);
}
Expand Down Expand Up @@ -398,8 +435,17 @@ 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(CustomerDefinition::ENTITY_NAME)
->withFieldName($key)
->withFieldSourcePath($value)
->withSourceData($originalData)
->withConvertedData($converted)
->build(FieldReassignedRunLog::class)
);
}
Expand All @@ -411,8 +457,13 @@ 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(CustomerDefinition::ENTITY_NAME)
->withFieldName('defaultShippingAddressId')
->withFieldSourcePath('default_shipping_address_id')
->withSourceData($originalData)
->withConvertedData($converted)
->build(FieldReassignedRunLog::class)
);
}
Expand All @@ -424,8 +475,13 @@ 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(CustomerDefinition::ENTITY_NAME)
->withFieldName('defaultBillingAddressId')
->withFieldSourcePath('default_shipping_address_id')
->withSourceData($originalData)
->withConvertedData($converted)
->build(FieldReassignedRunLog::class)
);
}
Expand All @@ -449,8 +505,14 @@ protected function getSalutation(string $gender): ?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('gender')
->withSourceData([
'gender' => $gender,
])
->build(UnknownEntityLog::class)
);

Expand All @@ -472,8 +534,11 @@ protected function getDefaultPaymentMethod(): ?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')
->build(UnknownEntityLog::class)
);

Expand Down
22 changes: 15 additions & 7 deletions src/Profile/Magento/Converter/NewsletterRecipientConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

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 Shopware\Core\System\SalesChannel\SalesChannelDefinition;
use Swag\MigrationMagento\Profile\Magento\DataSelection\DefaultEntities as MagentoDefaultEntities;
use Swag\MigrationMagento\Profile\Magento19\Premapping\Magento19NewsletterRecipientStatusReader;
use SwagMigrationAssistant\Migration\Converter\ConvertStruct;
Expand Down Expand Up @@ -52,9 +52,11 @@ public function convert(array $data, Context $context, MigrationContextInterface
);

if ($languageMapping === null) {
$this->loggingService->addLogEntry( // TODO: add optional fields
$this->loggingService->addLogEntry(
SwagMigrationLogBuilder::fromMigrationContext($migrationContext)
->withEntityName(DefaultEntities::NEWSLETTER_RECIPIENT)
->withEntityName(NewsletterRecipientDefinition::ENTITY_NAME)
->withFieldName('languageId')
->withSourceData($data)
->build(AssociationRequiredMissingLog::class)
);

Expand Down Expand Up @@ -129,9 +131,12 @@ private function getSalesChannelMapping(array $data, MigrationContextInterface $
);

if ($salesChannelMapping === null) {
$this->loggingService->addLogEntry( // TODO: add optional fields
$this->loggingService->addLogEntry(
SwagMigrationLogBuilder::fromMigrationContext($migrationContext)
->withEntityName(SalesChannelDefinition::ENTITY_NAME)
->withEntityName(NewsletterRecipientDefinition::ENTITY_NAME)
->withFieldName('salesChannelId')
->withFieldSourcePath('store_id')
->withSourceData($this->originalData)
->build(EmptyNecessaryFieldRunLog::class)
);
}
Expand All @@ -158,9 +163,12 @@ private function getStatus(array $data, MigrationContextInterface $migrationCont
}

if ($status === null) {
$this->loggingService->addLogEntry( // TODO: add optional fields
$this->loggingService->addLogEntry(
SwagMigrationLogBuilder::fromMigrationContext($migrationContext)
->withEntityName('status')
->withEntityName(NewsletterRecipientDefinition::ENTITY_NAME)
->withFieldName('status')
->withFieldSourcePath('default_newsletter_recipient_status')
->withSourceData($data)
->build(EmptyNecessaryFieldRunLog::class)
);
}
Expand Down
Loading