cancel
Showing results for 
Search instead for 
Did you mean: 

How do I save extra data in sales_order_item.product_options?

How do I save extra data in sales_order_item.product_options?

 

I'm facing a situation where I need to retrieve the custom option sku and price from a sales order item with custom options.

However it seems magento is only storing the custom option id and not the SKU or the price modification caused by the option

e.g. at table column sales_order_item.product_options

{
  "options": [
    {
      "label": "Test",
      "value": "Test",
      "print_value": "Test",
      "option_id": "23501",
      "option_type": "drop_down",
      "option_value": "136809",
      "custom_view": false
    },

  ]
}

The problem with this is that in my use case, the options are added / deleted dynamically so it's entirely possible that if the data is needed after the order is placed, the original option id no longer exists in the database to retrieve the SKU and the associated price tag.

Therefore I need a way to store this information in the options of the order item during place order.

Any ideas how I can achieve this?