Reputation: 36
We created an entity extension in the regular way https://developer.shopware.com/docs/guides/plugins/plugins/framework/data-handling/add-complex-data-to-existing-entities#entity-extension-vs.-custom-fields
Our entity extension extends the Category Entity and creates a ManyToOne Association to a custom entity
Entity Extension:
class CategoryWeingutseitenExtension extends EntityExtension
{
public function extendFields(FieldCollection $collection): void
{
$collection->add(
new OneToOneAssociationField('weingutseite', 'id', 'category_id', CategoryWeingutseitenExtensionDefinition::class, true)
);
}
public function getDefinitionClass(): string
{
return CategoryDefinition::class;
}
}
Entity Extension Definition:
class CategoryWeingutseitenExtensionDefinition extends EntityDefinition
{
public const ENTITY_NAME = 'airtable_category_weingutseiten_extension';
public function getEntityName(): string
{
return self::ENTITY_NAME;
}
public function getEntityClass(): string
{
return CategoryWeingutseitenExtensionEntity::class;
}
protected function defineFields(): FieldCollection
{
return new FieldCollection([
(new IdField('id','id'))->addFlags(new Required(), new PrimaryKey()),
(new FkField('category_id', 'categoryId', CategoryDefinition::class)),
(new FkField('weingutseiten_id', 'weingutseitenId', WeingutseitenDefinition::class)),
new OneToOneAssociationField('category', 'category_id', 'id', CategoryDefinition::class, false),
new ManyToOneAssociationField('weingutseite', 'weingutseiten_id', WeingutseitenDefinition::class, 'id', true)
]);
}
}
We managed to extend the regular category admin UI to assign this custom entity to a category. This works fine and vue auto loads the data in the category.extension.* like expected
As you can see, our associated model contains some media relations which we want to use in the category CMS elements.
Unfortunately only category.media appears in the CMS data mapping:
It seems like the sw-cms/service/cms.service.js receives the entity definition but without any extension field:
How can I manage to get the extension data into that entity definition as a property to use it in the cms-mapping-field?
Upvotes: 0
Views: 648
Reputation: 3190
That is currently not supported, best way to achieve that would be to create a PR yourself adding support for extensions there.
Otherwise please create a ticket at the official issue tracker, so support for that may be added by shopware.
Upvotes: 3