Product extension ManyToMany

Hello,

We want to assign in administration child products to a parent product.

We have a new column in product table ‚boxProducts‘.

We have a new table ‚nxs_box_product‘ with columns: product_id, child_id, product_version_id, created_at

We have new table definition:

return new FieldCollection([
            (new FkField('product_id', 'productId', ProductDefinition::class))->addFlags(new PrimaryKey(), new Required()),

            (new FkField('child_id', 'childId', ProductDefinition::class))->addFlags(new PrimaryKey(), new Required()),
            (new ReferenceVersionField(ProductDefinition::class))->addFlags(new PrimaryKey(), new Required()),

            new ManyToOneAssociationField('product', 'product_id', ProductDefinition::class, 'id', false),
            new ManyToOneAssociationField('nxs_box_product', 'child_id', ProductDefinition::class, 'id', false),

            new CreatedAtField(),
        ]);

We have product extension:

$collection->add(
            (new ManyToManyAssociationField(
                'boxProducts',
                ProductDefinition::class,
                ProductBoxDefinition::class,
                'product_id', //switching this with the below will not allow updates but have listing working
                'child_id'
            ))->addFlags(new Inherited())
        );

In the manner set above the data is written into the database but the retrieval in administration is not working.

In the manner when we switch in extension ‚product_id‘ with ‚child_id‘ it works to list the child products but the CUD operations fail.

Errors like

The nxs_box_product resource with the following primary key was not found: childId(8ae3754ca9e74c7ba1c492fa2fe72842) productId(2392378a80984440add2436ffac89c3b) productVersionId(0fa91ce3e96a4bc2be4bd9ce752c3425)

Actually the productId needs to be 8ae3754ca9e74c7ba1c492fa2fe72842 and childId 2392378a80984440add2436ffac89c3b.

We did not find the right setup when all the CRUD operations work all together.

We list in admin VUE js product details the children products like this:

The database structure is

CREATE TABLE `nxs_box_product` (
	`product_id` BINARY(16) NOT NULL,
	`child_id` BINARY(16) NOT NULL,
	`product_version_id` BINARY(16) NOT NULL,
	`created_at` DATETIME(3) NOT NULL,
	PRIMARY KEY (`product_id`, `child_id`, `product_version_id`),
	INDEX `fk.nxs_box_product.product_id__product_version_id` (`product_id`, `product_version_id`),
	INDEX `fk.nxs_box_product.child_id` (`child_id`),
	CONSTRAINT `fk.nxs_box_product.child_id` FOREIGN KEY (`child_id`) REFERENCES `product` (`id`) ON UPDATE CASCADE ON DELETE CASCADE,
	CONSTRAINT `fk.nxs_box_product.product_version_id__product_id` FOREIGN KEY (`product_id`, `product_version_id`) REFERENCES `product` (`id`, `version_id`) ON UPDATE CASCADE ON DELETE CASCADE
)
COLLATE='utf8mb4_unicode_ci'
ENGINE=InnoDB
;

Please assist as we are not able to list and update the list of parent product with its child products as a shopware standard ManyToMany relationship that relates on the same product definition.

Thank you,

AndreiB.