$position->
fromArray($data);
$position->
setOrder($order);
$this->
getManager()->
flush();
// If the passed data is a new position, the flush function will add the new id to the position model
$data['id'
] =
$position->
getId();
// The position model will refresh the product stock, so the product stock
// will be assigned to the view to refresh the grid or form panel.
$variant =
$this->
getManager()->
getRepository(ProductVariant::
class) ->
findOneBy(['number' =>
$position->
getArticleNumber()]);
if ($variant instanceof ProductVariant
) { $data['inStock'
] =
$variant->
getInStock();
} $order =
$this->
getRepository()->
find($order->
getId());
if (!
$order instanceof Order
) { $this->
View()->
assign([ 'success' => false,
'data' =>
$this->
Request()->
getParams(),
'message' =>
$namespace->
get('no_order_id_passed', 'No valid order id passed.'
),
]);