From 72b133564a871872f30b6ba25d4155d1941f0830 Mon Sep 17 00:00:00 2001 From: Stefan Rusche <37109200+srusche@users.noreply.github.com> Date: Tue, 3 Mar 2026 14:00:20 +0100 Subject: [PATCH 1/3] add CascadeDelete flag and explain effect on clone process --- .../data-handling/add-complex-data-to-existing-entities.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/guides/plugins/plugins/framework/data-handling/add-complex-data-to-existing-entities.md b/guides/plugins/plugins/framework/data-handling/add-complex-data-to-existing-entities.md index d7e1ff09d7..50ebed0f06 100644 --- a/guides/plugins/plugins/framework/data-handling/add-complex-data-to-existing-entities.md +++ b/guides/plugins/plugins/framework/data-handling/add-complex-data-to-existing-entities.md @@ -88,6 +88,7 @@ Let's start with the `CustomExtension` class by adding a new field in the `exten namespace Swag\BasicExample\Extension\Content\Product; use Shopware\Core\Content\Product\ProductDefinition; use Shopware\Core\Framework\DataAbstractionLayer\EntityExtension; +use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\CascadeDelete; use Shopware\Core\Framework\DataAbstractionLayer\Field\OneToOneAssociationField; use Shopware\Core\Framework\DataAbstractionLayer\FieldCollection; @@ -96,7 +97,7 @@ class CustomExtension extends EntityExtension public function extendFields(FieldCollection $collection): void { $collection->add( - new OneToOneAssociationField('exampleExtension', 'id', 'product_id', ExampleExtensionDefinition::class, true) + (new OneToOneAssociationField('exampleExtension', 'id', 'product_id', ExampleExtensionDefinition::class, true))->addFlags(new CascadeDelete()) ); } @@ -115,6 +116,9 @@ As you can see, we're adding a new `OneToOneAssociationField`. Its parameters ar * `referenceClass`: The class name of the definition that we want to connect via the association. * `autoload`: As the name suggests, this parameter defines if this association should always be loaded by default when the product is loaded. In this case, we definitely want that. +Associations marked with the `CascadeDelete` flag are are considered in the clone process ([see here](https://developer.shopware.com/docs/resources/references/adr/2020-07-02-control-clone-behavior.html)). +If the associated entity should not be cloned when cloning a product having it, change it to `CascadeDelete(false)` or remove the flag. + #### Creating ExampleExtensionDefinition You most likely noticed the new class `ExampleExtensionDefinition`, which we're going to create now. It will contain the actual string field that we wanted to add to the product. From e8ccc1138d7ad6630f56798c06cbff412a7f0960 Mon Sep 17 00:00:00 2001 From: Stefan Rusche <37109200+srusche@users.noreply.github.com> Date: Tue, 3 Mar 2026 16:03:19 +0100 Subject: [PATCH 2/3] Update guides/plugins/plugins/framework/data-handling/add-complex-data-to-existing-entities.md Co-authored-by: Michael Telgmann --- .../data-handling/add-complex-data-to-existing-entities.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guides/plugins/plugins/framework/data-handling/add-complex-data-to-existing-entities.md b/guides/plugins/plugins/framework/data-handling/add-complex-data-to-existing-entities.md index 50ebed0f06..0ee9e6514f 100644 --- a/guides/plugins/plugins/framework/data-handling/add-complex-data-to-existing-entities.md +++ b/guides/plugins/plugins/framework/data-handling/add-complex-data-to-existing-entities.md @@ -116,7 +116,7 @@ As you can see, we're adding a new `OneToOneAssociationField`. Its parameters ar * `referenceClass`: The class name of the definition that we want to connect via the association. * `autoload`: As the name suggests, this parameter defines if this association should always be loaded by default when the product is loaded. In this case, we definitely want that. -Associations marked with the `CascadeDelete` flag are are considered in the clone process ([see here](https://developer.shopware.com/docs/resources/references/adr/2020-07-02-control-clone-behavior.html)). +Associations marked with the `CascadeDelete` flag are considered in the clone process ([see here](https://developer.shopware.com/docs/resources/references/adr/2020-07-02-control-clone-behavior.html)). If the associated entity should not be cloned when cloning a product having it, change it to `CascadeDelete(false)` or remove the flag. #### Creating ExampleExtensionDefinition From f07a223a86103a2886842f2dd18272505e4571bd Mon Sep 17 00:00:00 2001 From: Su <112690947+sushmangupta@users.noreply.github.com> Date: Wed, 4 Mar 2026 06:31:16 +0100 Subject: [PATCH 3/3] Update guides/plugins/plugins/framework/data-handling/add-complex-data-to-existing-entities.md --- .../data-handling/add-complex-data-to-existing-entities.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guides/plugins/plugins/framework/data-handling/add-complex-data-to-existing-entities.md b/guides/plugins/plugins/framework/data-handling/add-complex-data-to-existing-entities.md index 0ee9e6514f..6b7930f751 100644 --- a/guides/plugins/plugins/framework/data-handling/add-complex-data-to-existing-entities.md +++ b/guides/plugins/plugins/framework/data-handling/add-complex-data-to-existing-entities.md @@ -116,7 +116,7 @@ As you can see, we're adding a new `OneToOneAssociationField`. Its parameters ar * `referenceClass`: The class name of the definition that we want to connect via the association. * `autoload`: As the name suggests, this parameter defines if this association should always be loaded by default when the product is loaded. In this case, we definitely want that. -Associations marked with the `CascadeDelete` flag are considered in the clone process ([see here](https://developer.shopware.com/docs/resources/references/adr/2020-07-02-control-clone-behavior.html)). +Associations marked with the `CascadeDelete` flag are considered in the clone process. Take a look at the [clone behaviour](../../../../../resources/references/adr/2020-07-02-control-clone-behavior.md) If the associated entity should not be cloned when cloning a product having it, change it to `CascadeDelete(false)` or remove the flag. #### Creating ExampleExtensionDefinition