Skip to content

Commit 5a379d1

Browse files
committed
fix: remove importExport profiles if there is more than one
1 parent b37a7ef commit 5a379d1

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "tinect/redirects",
33
"description": "Redirect plugin for Shopware 6",
4-
"version": "3.1.1",
4+
"version": "3.1.2",
55
"type": "shopware-platform-plugin",
66
"license": "MIT",
77
"authors": [

src/Migration/Migration1738788990ImportExportTechnicalName.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,23 @@ public function getCreationTimestamp(): int
1717

1818
public function update(Connection $connection): void
1919
{
20+
$count = (int)$connection->executeQuery(
21+
'SELECT COUNT(*) as count FROM import_export_profile WHERE source_entity = :sourceEntity AND system_default = 1',
22+
['sourceEntity' => RedirectDefinition::ENTITY_NAME]
23+
)->fetchOne();
24+
25+
if ($count > 1) {
26+
$connection->executeStatement(
27+
'DELETE FROM import_export_profile WHERE source_entity = :sourceEntity AND system_default = 1',
28+
['sourceEntity' => RedirectDefinition::ENTITY_NAME]
29+
);
30+
31+
$migration = new Migration1615031757ImportExportProfile();
32+
$migration->update($connection);
33+
34+
return;
35+
}
36+
2037
$connection->executeStatement(
2138
'UPDATE import_export_profile SET technical_name = :technicalName WHERE source_entity = :sourceEntity AND system_default = 1',
2239
[

0 commit comments

Comments
 (0)