gpt4 book ai didi

php - Shopware 6 : association with nested association, 这可能吗?

转载 作者:行者123 更新时间:2023-12-03 07:57:18 28 4
gpt4 key购买 nike

我的 EntityDefinition 中有一个关联:

...
class ParentEntityDefinition extends EntityDefinition
{
...
protected function defineFields(): FieldCollection
{
return new FieldCollection([

(new OneToOneAssociationField(
'childEntity',
'id',
'parent_entity_id',
ChildEntityDefinition::class,
false)),
]);
}

...
}

ChildEntity 有一个到currency_entity的fk_field。为了避免额外请求获取货币,我的问题:

  • 是否以及如果如何获取具有嵌套关联的货币实体?

最佳答案

是的,这是完全可能的。

您可以通过以下方式添加嵌套关联:

$criteria->addAssociation('childEntity.parentEntity');

请注意指定嵌套关联的点语法,相同的语法也可以用于 HTTP-API。

也请查看官方文档:https://developer.shopware.com/docs/guides/plugins/plugins/framework/data-handling/reading-data#associations

关于php - Shopware 6 : association with nested association, 这可能吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75723582/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com