cancel
Showing results for 
Search instead for 
Did you mean: 

Add option sku in order items API

Add option sku in order items API

Hi guys, I need to extend the orders API response.

In the item options section, the order API is something like that:

"custom_options": [

{

"option_id": "12276",

"option_value": "20"

}

I would like to add the option_sku:

"custom_options": [

  {

  "option_id": "12276",

  "option_value": "20"

  "option_sku":"myoptionsku"

  },

I don't understand where I should put my hands. I already spent a couple of hours googling around, but with no luck. Hope you can help me.

 

Thanks in advance

 

G

3 REPLIES 3

Re: Add option sku in order items API

You can use extension attributes for that.

Re: Add option sku in order items API

Hi @yashmbhaya4524, thanks for your reply.

I saw this:
https://devdocs.magento.com/guides/v2.4/extension-dev-guide/extension_attributes/adding-attributes.h...

May I ask you an advice to what should I do in my case? Magento is so tough, and the API are even tougher!

 

Thanks in advance

 

G

Re: Add option sku in order items API

Firstly you should learn it in basic, try to follow blog you shown me after you got desired output as per blog find which function magento calls at the time of of saving and giving value, you can save your custom extension attribute before magento saves data and add data before magento outputs it.