$position =
$this->
getManager()->
getRepository(OrderDetail::
class)->
find($id);
if (!
$position instanceof OrderDetail
) { $position =
new OrderDetail();
$attribute =
new OrderDetailAttribute();
$position->
setAttribute($attribute);
$this->
getManager()->
persist($position);
} $data =
$this->
Request()->
getParams();
$data['number'
] =
$order->
getNumber();
$data =
$this->
getPositionAssociatedData($data,
$order);
$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.