Hi,
We are developing an internal plugin that adds new fields as a extension to orders.
The extension definition’s defineFields
is:
protected function defineFields(): FieldCollection
{
return new FieldCollection([
(new IdField('id', 'id'))->addFlags(new Required(), new PrimaryKey()),
new VersionField(),
new ReferenceVersionField(OrderDefinition::class, 'order_version_id'),
new FkField('order_id', 'orderId', OrderDefinition::class),
(new JsonField('external_status', 'extensionStatus')),
(new OneToOneAssociationField('order', 'order_id', 'id', OrderDefinition::class, false))->addFlags(new ReverseInherited('productExtension'))->addFlags(new ApiAware()),
]);
}
When saving data with:
$this->orderRepository->update([
[
"id"=>$order->getId(),
"extensions"=>[
"externalOrder"=>[
"externalStatus"=>["id"=>$id, "warehouses"=>$warehouseResponses],
],
]
]
], $this->context);
The order_version_id
field doesn’t get set, and then when trying to read the data, $order->hasExtension("externalOrder")
returns false
.
Is there anything missing in the FieldCollection above?
Thank you.