Skip to content

Commit e2a5927

Browse files
fix: setup dal references correctly
1 parent eff2115 commit e2a5927

File tree

6 files changed

+28
-4
lines changed

6 files changed

+28
-4
lines changed

src/Content/MailArchive/MailArchiveDefinition.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Shopware\Core\Checkout\Customer\CustomerDefinition;
88
use Shopware\Core\Checkout\Order\OrderDefinition;
99
use Shopware\Core\Content\Flow\FlowDefinition;
10+
use Shopware\Core\Defaults;
1011
use Shopware\Core\Framework\DataAbstractionLayer\EntityDefinition;
1112
use Shopware\Core\Framework\DataAbstractionLayer\Field\FkField;
1213
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\AllowHtml;
@@ -19,6 +20,7 @@
1920
use Shopware\Core\Framework\DataAbstractionLayer\Field\LongTextField;
2021
use Shopware\Core\Framework\DataAbstractionLayer\Field\ManyToOneAssociationField;
2122
use Shopware\Core\Framework\DataAbstractionLayer\Field\OneToManyAssociationField;
23+
use Shopware\Core\Framework\DataAbstractionLayer\Field\ReferenceVersionField;
2224
use Shopware\Core\Framework\DataAbstractionLayer\Field\StringField;
2325
use Shopware\Core\Framework\DataAbstractionLayer\FieldCollection;
2426
use Shopware\Core\System\SalesChannel\SalesChannelDefinition;
@@ -39,6 +41,13 @@ public function getEntityClass(): string
3941
return MailArchiveEntity::class;
4042
}
4143

44+
public function getDefaults(): array
45+
{
46+
return [
47+
'orderVersionId' => Defaults::LIVE_VERSION
48+
];
49+
}
50+
4251
protected function defineFields(): FieldCollection
4352
{
4453
return new FieldCollection([
@@ -60,6 +69,7 @@ protected function defineFields(): FieldCollection
6069
new ManyToOneAssociationField('customer', 'customerId', CustomerDefinition::class, 'id', true),
6170

6271
new FkField('order_id', 'orderId', OrderDefinition::class),
72+
new ReferenceVersionField(OrderDefinition::class, 'order_version_id'),
6373
new ManyToOneAssociationField('order', 'order_id', OrderDefinition::class, 'id', false),
6474

6575
new FkField('flow_id', 'flowId', FlowDefinition::class),

src/Content/MailArchive/MailArchiveEntity.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ class MailArchiveEntity extends Entity
4242

4343
protected ?string $orderId;
4444

45+
protected ?string $orderVersionId;
46+
4547
protected ?OrderEntity $order;
4648

4749
protected ?string $flowId;
@@ -277,4 +279,14 @@ public function setFlow(?FlowEntity $flow): void
277279
$this->flow = $flow;
278280
}
279281

282+
public function getOrderVersionId(): ?string
283+
{
284+
return $this->orderVersionId;
285+
}
286+
287+
public function setOrderVersionId(?string $orderVersionId): void
288+
{
289+
$this->orderVersionId = $orderVersionId;
290+
}
291+
280292
}

src/Extension/Checkout/Customer/CustomerExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function extendFields(FieldCollection $collection): void
2222
'froshMailArchive',
2323
MailArchiveDefinition::class,
2424
'customerId',
25-
))->addFlags(new SetNullOnDelete()),
25+
))->addFlags(new SetNullOnDelete(false)),
2626
);
2727
}
2828

src/Extension/Checkout/Order/OrderExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function extendFields(FieldCollection $collection): void
2323
'froshMailArchive',
2424
MailArchiveDefinition::class,
2525
'order_id',
26-
))->addFlags(new SetNullOnDelete()),
26+
))->addFlags(new SetNullOnDelete(false)),
2727
);
2828
}
2929
}

src/Extension/Content/Flow/FlowExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function extendFields(FieldCollection $collection): void
2323
'froshMailArchive',
2424
MailArchiveDefinition::class,
2525
'flow_id',
26-
))->addFlags(new SetNullOnDelete()),
26+
))->addFlags(new SetNullOnDelete(false)),
2727
);
2828
}
2929
}

src/Migration/Migration1739730285AddOrderId.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ public function update(Connection $connection): void
1818
{
1919
$connection->executeStatement('
2020
ALTER TABLE `frosh_mail_archive`
21-
ADD COLUMN `order_id` BINARY(16) NULL;
21+
ADD COLUMN `order_id` BINARY(16) NULL,
22+
ADD COLUMN `order_version_id` BINARY(16) NULL
23+
;
2224
');
2325
}
2426

0 commit comments

Comments
 (0)