I am programatically saving orders. I need to be able to set a custom data for order items in
sales_order_item table. What is the best way to do this?
I notice there is an
additional_data column which looks ideal, however, I don't seem to be able to save data to it.
Code of what I've tried below...
$cartId = $this->cartManagementInterface->createEmptyCart(); $quote = $this->cartRepositoryInterface->get($cartId); $product=$this->_product->load(1); /** * Try to add the column here */ $product->setData('additional_data', json_encode(["ewfe" => 'wefwef'])); $quote->addProduct($product, 1); // Set all shipping / customer details etc $quote->getPayment()->importData(['method' => 'checkmo']); $quote->save(); $quote->collectTotals(); // Create Order From Quote $quote = $this->cartRepositoryInterface->get($quote->getId()); $orderId = $this->cartManagementInterface->placeOrder($quote->getId());
Running this saves the order, but does not add any data to the additional_data column.