I have created 2 tables like the following
CREATE TABLE IF NOT EXISTS `swag_product_extension`(
`id` BINARY(16) NOT NULL,
`product_id` BINARY(16) NOT NULL,
`product_version_id` BINARY(16) NOT NULL,
`created_at` DATETIME(3) NOT NULL,
`updated_at` DATETIME(3) NULL,
PRIMARY KEY(`id`),
CONSTRAINT `fk.swag_product_extension.product_id` FOREIGN KEY(`product_id`, `product_version_id`) REFERENCES `product`(`id`, `version_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
CREATE TABLE IF NOT EXISTS `swag_product_extension_translation`(
`swag_product_extension_id` BINARY(16) NOT NULL,
`language_id` BINARY(16) NOT NULL,
`info` VARCHAR(255) NULL,
`created_at` DATETIME(3) NOT NULL,
`updated_at` DATETIME(3) NULL,
PRIMARY KEY(
`swag_product_extension_id`,
`language_id`
),
CONSTRAINT `fk.swag_product_extension_translation.swag_product_extension_id` FOREIGN KEY(`swag_product_extension_id`) REFERENCES `swag_product_extension`(`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `fk.swag_product_extension_translation.language_id` FOREIGN KEY(`language_id`) REFERENCES `language`(`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
$this->updateInheritance($connection, 'product', 'productExtension');
Then i extended the product entity using EntityExtension
$collection->add(
(new OneToOneAssociationField(
'productExtension',
'id',
'product_id',
ProductExtensionDefinition::class,
true
))->addFlags(new Inherited())
);
ProductExtensionDefinition
return new FieldCollection(
[
(new IdField('id', 'id'))->addFlags(new ApiAware(), new Required(), new PrimaryKey()),
(new FkField('product_id', 'productId', ProductDefinition::class))->addFlags(new ApiAware(), new Required()),
(new ReferenceVersionField(ProductDefinition::class))->addFlags(new Required()),
(new TranslatedField('info'))->addFlags(new ApiAware()),
(new TranslationsAssociationField(
ProductExtensionTranslationDefinition::class,
'swag_product_extension_id'))->addFlags(new ApiAware()),
(new OneToOneAssociationField('product', 'product_id', 'id', ProductDefinition::class, false))->addFlags(new ReverseInherited('productExtension'))
]);
ProductExtensionTranslationDefinition
protected function defineFields(): FieldCollection
{
return new FieldCollection([
(new StringField('info', 'info'))->addFlags(new ApiAware())
]);
}
The inheritance is working fine in the backend
But inheritance not working in the front end
Any solution for this issue?