I'm trying to add additional options to the product, it is working fine to add attributes programmatically on the website but how to add these additional attributes to the REST API.
public function aroundConvert(
\Magento\Quote\Model\Quote\Item\ToOrderItem $subject,
Closure $proceed,
\Magento\Quote\Model\Quote\Item\AbstractItem $item,
$additional = []
) {
/** @var $orderItem \Magento\Sales\Model\Order\Item */
$orderItem = $proceed($item, $additional);//result of function 'convert' in class 'Magento\Quote\Model\Quote\Item\ToOrderItem'
if ($additionalOptions = $item->getOptionByCode('additional_options')) {
$options = $orderItem->getProductOptions();
$options['additional_options'] = $this->serialize->unserialize($additionalOptions->getValue());
$orderItem->setProductOptions($options);
return $orderItem;
}
return $orderItem;
}
When I try to add an additional option to REST API: V1/carts/mine/items
I'm getting the following error.
"Property "AdditionalOptions" does not have accessor method "getAdditionalOptions" in class "Magento\Catalog\Api\Data\CustomOptionInterface"."
Below is my request packet:
{
"cartItem": {
"sku": "MEW001",
"qty": 1,
"quote_id": "126252",
"product_option": {
"extension_attributes": {
"custom_options": [
{
"additional_options":
{
"price":"200.000000",
"send_friend":"1",
"customer_name":"Sender Name",
"recipient_name":"Friend",
"recipient_email":"sendto@email.com",
"message":"xyz"
}
}
]
}
}
}
}
And the screenshot.