Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
d6f73ba
Merge branch 'trunk' of github.com:shopware/SwagMigrationAssistant in…
DennisGarding Sep 23, 2025
3cf6d32
Merge branch 'feature/migration-logging-refactor' of github.com:shopw…
DennisGarding Sep 24, 2025
5ad6e0a
Merge branch 'feature/migration-logging-refactor' of github.com:shopw…
DennisGarding Oct 23, 2025
0bc9d86
Merge branch 'feature/migration-logging-refactor' of github.com:shopw…
DennisGarding Oct 28, 2025
b028a3b
chore: remove validation from converter
DennisGarding Oct 30, 2025
e00d8dd
Merge branch 'feature/migration-logging-refactor' of github.com:shopw…
DennisGarding Oct 31, 2025
0ed185f
Fix cs
DennisGarding Oct 31, 2025
3b6460f
Fix phpstan issues
DennisGarding Oct 31, 2025
ab6740a
Fix cs
DennisGarding Oct 31, 2025
6e56dbd
Fix test
DennisGarding Oct 31, 2025
dd94888
Fix test
DennisGarding Oct 31, 2025
4e77b2f
Fix test
DennisGarding Oct 31, 2025
9c7a195
Remove comment
DennisGarding Oct 31, 2025
9c5961e
Merge branch 'feature/migration-logging-refactor' of github.com:shopw…
DennisGarding Nov 3, 2025
3c94193
Fix issues
DennisGarding Nov 3, 2025
92419d8
Merge branch 'feature/migration-logging-refactor' of github.com:shopw…
DennisGarding Nov 11, 2025
302c381
Change
DennisGarding Nov 11, 2025
7447c4f
Fix test
DennisGarding Nov 11, 2025
fbb83e2
Fix test
DennisGarding Nov 11, 2025
408ad3a
Add keys to dataprovider
DennisGarding Nov 12, 2025
9ff744f
Fix cs
DennisGarding Nov 12, 2025
7d5a29e
Fix comments
DennisGarding Nov 12, 2025
b8af7d3
Fix comments
DennisGarding Nov 12, 2025
fbe3e52
Fix tests
DennisGarding Nov 13, 2025
da4ff75
Merge branch 'feature/migration-logging-refactor' of github.com:shopw…
DennisGarding Nov 24, 2025
a1f6d55
Early return (null) in converter
DennisGarding Nov 24, 2025
3a53195
Merge branch 'feature/migration-logging-refactor' of github.com:shopw…
DennisGarding Dec 1, 2025
2893e6a
fix code style
DennisGarding Dec 1, 2025
adeb9bb
fix cs and tests
DennisGarding Dec 2, 2025
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
2 changes: 1 addition & 1 deletion src/DependencyInjection/shopware.xml
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@

<service id="SwagMigrationAssistant\Profile\Shopware\Converter\LanguageConverter"
parent="SwagMigrationAssistant\Profile\Shopware\Converter\ShopwareConverter" abstract="true">
<argument type="service" id="SwagMigrationAssistant\Migration\Mapping\Lookup\LanguageLookup"/>
<argument type="service" id="SwagMigrationAssistant\Migration\Mapping\Lookup\LocaleLookup"/>
<argument type="service" id="SwagMigrationAssistant\Migration\Mapping\Lookup\LanguageLookup"/>
</service>

<service id="SwagMigrationAssistant\Profile\Shopware\Converter\SalesChannelConverter"
Expand Down
4 changes: 3 additions & 1 deletion src/Migration/Converter/ConverterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ public function getMediaUuids(array $converted): ?array;
/**
* Converts the given data into the internal structure
*
* A converter also could return null in various cases
*
* @param array<string, mixed> $data
*/
public function convert(array $data, Context $context, MigrationContextInterface $migrationContext): ConvertStruct;
public function convert(array $data, Context $context, MigrationContextInterface $migrationContext): ?ConvertStruct;

public function writeMapping(Context $context): void;
}
30 changes: 30 additions & 0 deletions src/Migration/Logging/Log/MainVariantRelationNotConverted.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php declare(strict_types=1);
/*
* (c) shopware AG <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace SwagMigrationAssistant\Migration\Logging\Log;

use Shopware\Core\Framework\Log\Package;
use SwagMigrationAssistant\Migration\Logging\Log\Builder\AbstractMigrationLogEntry;

#[Package('after-sales')]
readonly class MainVariantRelationNotConverted extends AbstractMigrationLogEntry
{
public function getLevel(): string
{
return self::LOG_LEVEL_ERROR;
}

public function getCode(): string
{
return 'SWAG_MIGRATION__MAIN_VARIANT_RELATION_NOT_CONVERTED';
}

public function isUserFixable(): bool
{
return false;
}
}
30 changes: 30 additions & 0 deletions src/Migration/Logging/Log/NotConvertedLog.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php declare(strict_types=1);
/*
* (c) shopware AG <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace SwagMigrationAssistant\Migration\Logging\Log;

use Shopware\Core\Framework\Log\Package;
use SwagMigrationAssistant\Migration\Logging\Log\Builder\AbstractMigrationLogEntry;

#[Package('after-sales')]
readonly class NotConvertedLog extends AbstractMigrationLogEntry
{
public function getLevel(): string
{
return self::LOG_LEVEL_INFO;
}

public function getCode(): string
{
return 'SWAG_MIGRATION__ENTITY_NOT_CONVERTED';
}

public function isUserFixable(): bool
{
return false;
}
}
13 changes: 13 additions & 0 deletions src/Migration/Service/MigrationDataConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
use Shopware\Core\Framework\Util\Hasher;
use SwagMigrationAssistant\Migration\Converter\ConverterInterface;
use SwagMigrationAssistant\Migration\Converter\ConverterRegistryInterface;
use SwagMigrationAssistant\Migration\Converter\ConvertStruct;
use SwagMigrationAssistant\Migration\DataSelection\DataSet\DataSet;
use SwagMigrationAssistant\Migration\Logging\Log\Builder\MigrationLogBuilder;
use SwagMigrationAssistant\Migration\Logging\Log\ExceptionRunLog;
use SwagMigrationAssistant\Migration\Logging\Log\NotConvertedLog;
use SwagMigrationAssistant\Migration\Logging\LoggingServiceInterface;
use SwagMigrationAssistant\Migration\Mapping\MappingDeltaResult;
use SwagMigrationAssistant\Migration\Mapping\MappingServiceInterface;
Expand Down Expand Up @@ -96,6 +98,17 @@ private function convertData(
foreach ($data as $item) {
try {
$convertStruct = $converter->convert($item, $context, $migrationContext);
if (!$convertStruct instanceof ConvertStruct) {
$this->loggingService->addLogEntry(
MigrationLogBuilder::fromMigrationContext($migrationContext)
->withSourceData($item)
->withEntityName($dataSet::getEntity())
->build(NotConvertedLog::class)
);

continue;
}

$convertFailureFlag = empty($convertStruct->getConverted());

$this->validationService->validate(
Expand Down
33 changes: 13 additions & 20 deletions src/Profile/Shopware/Converter/CategoryConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
use SwagMigrationAssistant\Exception\MigrationException;
use SwagMigrationAssistant\Migration\Converter\ConvertStruct;
use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities;
use SwagMigrationAssistant\Migration\Logging\Log\Builder\MigrationLogBuilder;
use SwagMigrationAssistant\Migration\Logging\Log\EmptyNecessaryFieldRunLog;
use SwagMigrationAssistant\Migration\Logging\LoggingServiceInterface;
use SwagMigrationAssistant\Migration\Mapping\Lookup\DefaultCmsPageLookup;
use SwagMigrationAssistant\Migration\Mapping\Lookup\LanguageLookup;
Expand All @@ -37,7 +35,7 @@ abstract class CategoryConverter extends ShopwareConverter

protected string $oldCategoryId;

protected string $locale;
protected ?string $locale = null;

protected string $runId;

Expand Down Expand Up @@ -84,19 +82,13 @@ public function convert(
$this->connectionId = $connection->getId();
$this->connectionName = $connection->getName();

if (!isset($data['_locale'])) {
$this->loggingService->addLogEntry(
MigrationLogBuilder::fromMigrationContext($migrationContext)
->withEntityName(CategoryDefinition::ENTITY_NAME)
->withFieldSourcePath('_locale')
->withSourceData($data)
->build(EmptyNecessaryFieldRunLog::class)
);
$converted = [];

return new ConvertStruct(null, $data);
if (isset($data['_locale'])) {
$this->locale = $data['_locale'];
} else {
$this->locale = null;
}
$this->locale = $data['_locale'];
$converted = [];

$cmsPageUuid = $this->defaultCmsPageLookup->get($context);
if ($cmsPageUuid !== null) {
Expand Down Expand Up @@ -244,8 +236,7 @@ protected function setGivenCategoryTranslation(array &$data, array &$converted):
}

$locale = $language->getLocale();

if ($locale === null || $locale->getCode() === $data['_locale']) {
if (!isset($data['_locale']) || $locale?->getCode() === $data['_locale']) {
return;
}

Expand Down Expand Up @@ -364,10 +355,12 @@ protected function addMediaTranslation(array &$media, array $data): void
$localeTranslation['id'] = $mapping['entityId'];
$this->mappingIds[] = $mapping['id'];

$languageUuid = $this->languageLookup->get($this->locale, $this->context);
if ($languageUuid !== null) {
$localeTranslation['languageId'] = $languageUuid;
$media['translations'][$languageUuid] = $localeTranslation;
if ($this->locale !== null) {
$languageUuid = $this->languageLookup->get($this->locale, $this->context);
if ($languageUuid !== null) {
$localeTranslation['languageId'] = $languageUuid;
$media['translations'][$languageUuid] = $localeTranslation;
}
}
}
}
43 changes: 10 additions & 33 deletions src/Profile/Shopware/Converter/CrossSellingConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@

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;
use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities;
use SwagMigrationAssistant\Migration\Logging\Log\AssociationRequiredMissingLog;
use SwagMigrationAssistant\Migration\Logging\Log\Builder\MigrationLogBuilder;
use SwagMigrationAssistant\Migration\MigrationContextInterface;

#[Package('fundamentals@after-sales')]
Expand Down Expand Up @@ -59,36 +56,14 @@ public function convert(array $data, Context $context, MigrationContextInterface
$converted['id'] = $crossSellingMapping['entityId'];

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

return new ConvertStruct(null, $data);
if ($sourceProductMapping !== null) {
$this->mappingIds[] = $sourceProductMapping['id'];
}
$this->mappingIds[] = $sourceProductMapping['id'];

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

return new ConvertStruct(null, $data);
if ($relatedProductMapping !== null) {
$this->mappingIds[] = $relatedProductMapping['id'];
}
$this->mappingIds[] = $relatedProductMapping['id'];

if ($data['type'] === DefaultEntities::CROSS_SELLING_SIMILAR) {
$converted['name'] = 'Similar Items';
Expand All @@ -105,15 +80,17 @@ public function convert(array $data, Context $context, MigrationContextInterface

$converted['type'] = 'productList';
$converted['active'] = true;
$converted['productId'] = $sourceProductMapping['entityId'];
$converted['assignedProducts'] = [
[
'id' => $relationMapping['entityId'],
'position' => $data['position'],
'productId' => $relatedProductMapping['entityId'],
'id' => $relationMapping['entityId'] ?? null,
'position' => $data['position'] ?? null,
'productId' => $relatedProductMapping['entityId'] ?? null,
],
];

if (isset($sourceProductMapping['entityId'])) {
$converted['productId'] = $sourceProductMapping['entityId'];
}
unset(
$data['type'],
$data['id'],
Expand Down
4 changes: 2 additions & 2 deletions src/Profile/Shopware/Converter/CurrencyConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function getSourceIdentifier(array $data): string
return $data['currency'];
}

public function convert(array $data, Context $context, MigrationContextInterface $migrationContext): ConvertStruct
public function convert(array $data, Context $context, MigrationContextInterface $migrationContext): ?ConvertStruct
{
$this->generateChecksum($data);
$this->context = $context;
Expand All @@ -63,7 +63,7 @@ public function convert(array $data, Context $context, MigrationContextInterface
);
}

return new ConvertStruct(null, $data);
return null;
}

$converted = [];
Expand Down
Loading
Loading