I am using Magento 2.3.4, and i created custom attibute in quote_item 'up_flag'. and throgh rest api i am passing the value of "up_flag":
Post request Body for V1/carts/mine/items:
{"cartItem": {"sku": "xxxx", "qty": "1", "quote_id": 28981,"up_flag": "1"}}
and i am getting the error "Message: Property "UpFlag" does not have accessor method"
or if i try through Extension attribute method like:
{"cartItem": {"sku": "xxxx", "qty": "1", "quote_id": 28975,
"extension_attributes": {
"up_flag": "1"
}
}}
And Plugins Code:
public function afterGet(
CartRepositoryInterface $subject,
CartInterface $resultEntity
) {
foreach ($resultEntity->getItems() as $item) {
$extensionAttributes = $item->getExtensionAttributes();
if (!$extensionAttributes) {
$extensionAttributes = $this->totalsItemExtensionInterfaceFactory->create();
}
$getupflag = $extensionAttributes->getUpFlag();
$extensionAttributes->setUpFlag($getupflag);
$item->setExtensionAttributes($extensionAttributes);
}
return $resultEntity;
}
Response in Postman:
NULL
NULL
string(1) "1"
NULL
string(1) "1"
{
"item_id": 5222,
"sku": "PGKFMT1",
"qty": 9,
"name": "XXXXX",
"price": 237.29,
"product_type": "simple",
"quote_id": "28981",
"extension_attributes": {
"discounts": [
{
"discount_data": {
"amount": 126,
"base_amount": 126,
"original_amount": 135,
"base_original_amount": 135
},
"rule_label": "5% discount for prepaid",
"rule_id": 20
},
{
"discount_data": {
"amount": 239.4,
"base_amount": 239.4,
"original_amount": 257.4,
"base_original_amount": 257.4
},
"rule_label": "discount",
"rule_id": 6
}
],
"image_url": "http://localhost/default/pub/static/version1604919926/webapi_rest/_view/en_US/Magento_Catalog/images/product/placeholder/.jpg"
}
}
Now i always getting first the value fo $getupflag = Null and its not showing in response. even how i can save "up_flag" value in DB?