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();



    return $resultEntity;

Response in Postman:

string(1) "1"
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?


I suggest you to create extension attribute like it is explained here . And then, when you have extension attribute, you can send it to API and update it. Remember that extension attribute and some custom attribute is different. Not really sure which one you created, since you say you created custom attribute, but also trying extension attribute update. Anyway, I suggest you to create extension attribute and use it. It is suggested way by Magento2. Also with example it is kind of easy way to implement.

  • Hi @Kestutisk, i tried with Extension attribute only, please check my update question. – sam Nov 18 '20 at 6:24
  • You also need to create afterSave and afterGetList plugins for extension attributes. afterSave should save to database, that is what it for. – KestutisK Nov 18 '20 at 7:12
  • after create this plugin, product is not added in cart for guest customer? – sam Nov 19 '20 at 9:42
  • Use xdebug and see what happens. Could be it brakes on some line – KestutisK Nov 19 '20 at 9:59
  • If you have any sample code, can you please share. i tried with add another two method also, but showing always some issue. – sam Nov 23 '20 at 5:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.