Magento 2 How to add custom attribute to Quote Item Rest API The 2019 Stack Overflow Developer Survey Results Are InMagento 2 CMS Page getList() repository methods does not return expected objectmain.CRITICAL: Plugin class doesn't existMagento2 add custom address attributeAdd value for custom quote item attribute using REST apiHow to add new field in the Default API responseMagento 2 - Save Extension Attribute afterSave() returns voidCart page error in Magento 2.2.3Add configure product in Cart using Magento 2 API facing an issueMagento2 REST API get all customers detailsMagento 2 REST - SKU to items on cart totals API response is not available, How to get SKU in response API

Have you ever entered Singapore using a different passport or name?

How to support a colleague who finds meetings extremely tiring?

What does Linus Torvalds mean when he says that Git "never ever" tracks a file?

Return to UK after being refused entry years previously

Why did Acorn's A3000 have red function keys?

Is this app Icon Browser Safe/Legit?

Is there a symbol for a right arrow with a square in the middle?

Loose spokes after only a few rides

Which Sci-Fi work first showed weapon of galactic-scale mass destruction?

Time travel alters history but people keep saying nothing's changed

For what reasons would an animal species NOT cross a *horizontal* land bridge?

Identify boardgame from Big movie

Why is the maximum length of OpenWrt’s root password 8 characters?

Did 3000BC Egyptians use meteoric iron weapons?

What is the meaning of the verb "bear" in this context?

During Temple times, who can butcher a kosher animal?

How technical should a Scrum Master be to effectively remove impediments?

Did Scotland spend $250,000 for the slogan "Welcome to Scotland"?

Can a rogue use sneak attack with weapons that have the thrown property even if they are not thrown?

If a Druid sees an animal’s corpse, can they wild shape into that animal?

Pokemon Turn Based battle (Python)

Are there any other methods to apply to solving simultaneous equations?

Protecting Dualbooting Windows from dangerous code (like rm -rf)

When should I buy a clipper card after flying to OAK?



Magento 2 How to add custom attribute to Quote Item Rest API



The 2019 Stack Overflow Developer Survey Results Are InMagento 2 CMS Page getList() repository methods does not return expected objectmain.CRITICAL: Plugin class doesn't existMagento2 add custom address attributeAdd value for custom quote item attribute using REST apiHow to add new field in the Default API responseMagento 2 - Save Extension Attribute afterSave() returns voidCart page error in Magento 2.2.3Add configure product in Cart using Magento 2 API facing an issueMagento2 REST API get all customers detailsMagento 2 REST - SKU to items on cart totals API response is not available, How to get SKU in response API



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I want to add custom attribute to http://magento2/rest/V1/carts/mine/totals API response.



I have done follwing way but it not working.



extension_attributes.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Api/etc/extension_attributes.xsd">
<extension_attributes for="MagentoQuoteApiDataCartItemInterface">
<attribute code="product_option" type="float" />
</extension_attributes>
</config>

di.xml

<type name="MagentoQuoteModelQuoteItem">
<plugin name="cs_product_opt" type="NamespaceProductPluginModelCartCartTotalRepositoryPlugin" />
</type>

Plugin file

<?php
/**
* Copyright 2016 aheadWorks. All rights reserved.
* See LICENSE.txt for license details.
*/

namespace NamespaceProductPluginModelCart;

use MagentoQuoteApiDataTotalsExtensionInterface;
use MagentoQuoteApiDataTotalsExtensionFactory;
use MagentoQuoteApiDataCartItemExtensionFactory;
use MagentoQuoteApiDataTotalsInterface;
use MagentoQuoteApiCartRepositoryInterface;
use MagentoQuoteModelCartCartTotalRepository as TotalRepository;
use MagentoQuoteModelQuote;

/**
* Class AheadworksStoreCreditPluginModelCartCartTotalRepositoryPlugin
*/
class CartTotalRepositoryPlugin

/**
* @var CartRepositoryInterface
*/
private $quoteRepository;

/**
* @var CartItemExtensionFactory
*/
private $totalsExtensionFactory;

/**
* @param CartRepositoryInterface $quoteRepository
* @param CartItemExtensionFactory $totalsExtensionFactory
*/
public function __construct(
CartRepositoryInterface $quoteRepository,
CartItemExtensionFactory $totalsExtensionFactory
)
$this->quoteRepository = $quoteRepository;
$this->totalsExtensionFactory = $totalsExtensionFactory;


/**
* Apply extension attributes to totals
*
* @param TotalRepository $subject
* @param Closure $proceed
* @param int $cartId
* @return TotalsInterface
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function aroundGet(TotalRepository $subject, Closure $proceed, $cartId)

/** @var TotalsInterface $totals */
$totals = $proceed($cartId);

/** @var MagentoQuoteApiDataTotalsExtensionInterface $extensionAttributes */
$extensionAttributes = $totals->getExtensionAttributes()
? $totals->getExtensionAttributes()
: $this->totalsExtensionFactory->create();

/** @var Quote $quote */
$quote = $this->quoteRepository->getActive($cartId);

$extensionAttributes->setProductOption(1.11);
$totals->setExtensionAttributes($extensionAttributes);
return $totals;




anyone have idea how to add custom attribute to Quote Item Rest API.










share|improve this question














bumped to the homepage by Community 8 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.





















    0















    I want to add custom attribute to http://magento2/rest/V1/carts/mine/totals API response.



    I have done follwing way but it not working.



    extension_attributes.xml

    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Api/etc/extension_attributes.xsd">
    <extension_attributes for="MagentoQuoteApiDataCartItemInterface">
    <attribute code="product_option" type="float" />
    </extension_attributes>
    </config>

    di.xml

    <type name="MagentoQuoteModelQuoteItem">
    <plugin name="cs_product_opt" type="NamespaceProductPluginModelCartCartTotalRepositoryPlugin" />
    </type>

    Plugin file

    <?php
    /**
    * Copyright 2016 aheadWorks. All rights reserved.
    * See LICENSE.txt for license details.
    */

    namespace NamespaceProductPluginModelCart;

    use MagentoQuoteApiDataTotalsExtensionInterface;
    use MagentoQuoteApiDataTotalsExtensionFactory;
    use MagentoQuoteApiDataCartItemExtensionFactory;
    use MagentoQuoteApiDataTotalsInterface;
    use MagentoQuoteApiCartRepositoryInterface;
    use MagentoQuoteModelCartCartTotalRepository as TotalRepository;
    use MagentoQuoteModelQuote;

    /**
    * Class AheadworksStoreCreditPluginModelCartCartTotalRepositoryPlugin
    */
    class CartTotalRepositoryPlugin

    /**
    * @var CartRepositoryInterface
    */
    private $quoteRepository;

    /**
    * @var CartItemExtensionFactory
    */
    private $totalsExtensionFactory;

    /**
    * @param CartRepositoryInterface $quoteRepository
    * @param CartItemExtensionFactory $totalsExtensionFactory
    */
    public function __construct(
    CartRepositoryInterface $quoteRepository,
    CartItemExtensionFactory $totalsExtensionFactory
    )
    $this->quoteRepository = $quoteRepository;
    $this->totalsExtensionFactory = $totalsExtensionFactory;


    /**
    * Apply extension attributes to totals
    *
    * @param TotalRepository $subject
    * @param Closure $proceed
    * @param int $cartId
    * @return TotalsInterface
    * @SuppressWarnings(PHPMD.UnusedFormalParameter)
    */
    public function aroundGet(TotalRepository $subject, Closure $proceed, $cartId)

    /** @var TotalsInterface $totals */
    $totals = $proceed($cartId);

    /** @var MagentoQuoteApiDataTotalsExtensionInterface $extensionAttributes */
    $extensionAttributes = $totals->getExtensionAttributes()
    ? $totals->getExtensionAttributes()
    : $this->totalsExtensionFactory->create();

    /** @var Quote $quote */
    $quote = $this->quoteRepository->getActive($cartId);

    $extensionAttributes->setProductOption(1.11);
    $totals->setExtensionAttributes($extensionAttributes);
    return $totals;




    anyone have idea how to add custom attribute to Quote Item Rest API.










    share|improve this question














    bumped to the homepage by Community 8 mins ago


    This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.

















      0












      0








      0


      1






      I want to add custom attribute to http://magento2/rest/V1/carts/mine/totals API response.



      I have done follwing way but it not working.



      extension_attributes.xml

      <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Api/etc/extension_attributes.xsd">
      <extension_attributes for="MagentoQuoteApiDataCartItemInterface">
      <attribute code="product_option" type="float" />
      </extension_attributes>
      </config>

      di.xml

      <type name="MagentoQuoteModelQuoteItem">
      <plugin name="cs_product_opt" type="NamespaceProductPluginModelCartCartTotalRepositoryPlugin" />
      </type>

      Plugin file

      <?php
      /**
      * Copyright 2016 aheadWorks. All rights reserved.
      * See LICENSE.txt for license details.
      */

      namespace NamespaceProductPluginModelCart;

      use MagentoQuoteApiDataTotalsExtensionInterface;
      use MagentoQuoteApiDataTotalsExtensionFactory;
      use MagentoQuoteApiDataCartItemExtensionFactory;
      use MagentoQuoteApiDataTotalsInterface;
      use MagentoQuoteApiCartRepositoryInterface;
      use MagentoQuoteModelCartCartTotalRepository as TotalRepository;
      use MagentoQuoteModelQuote;

      /**
      * Class AheadworksStoreCreditPluginModelCartCartTotalRepositoryPlugin
      */
      class CartTotalRepositoryPlugin

      /**
      * @var CartRepositoryInterface
      */
      private $quoteRepository;

      /**
      * @var CartItemExtensionFactory
      */
      private $totalsExtensionFactory;

      /**
      * @param CartRepositoryInterface $quoteRepository
      * @param CartItemExtensionFactory $totalsExtensionFactory
      */
      public function __construct(
      CartRepositoryInterface $quoteRepository,
      CartItemExtensionFactory $totalsExtensionFactory
      )
      $this->quoteRepository = $quoteRepository;
      $this->totalsExtensionFactory = $totalsExtensionFactory;


      /**
      * Apply extension attributes to totals
      *
      * @param TotalRepository $subject
      * @param Closure $proceed
      * @param int $cartId
      * @return TotalsInterface
      * @SuppressWarnings(PHPMD.UnusedFormalParameter)
      */
      public function aroundGet(TotalRepository $subject, Closure $proceed, $cartId)

      /** @var TotalsInterface $totals */
      $totals = $proceed($cartId);

      /** @var MagentoQuoteApiDataTotalsExtensionInterface $extensionAttributes */
      $extensionAttributes = $totals->getExtensionAttributes()
      ? $totals->getExtensionAttributes()
      : $this->totalsExtensionFactory->create();

      /** @var Quote $quote */
      $quote = $this->quoteRepository->getActive($cartId);

      $extensionAttributes->setProductOption(1.11);
      $totals->setExtensionAttributes($extensionAttributes);
      return $totals;




      anyone have idea how to add custom attribute to Quote Item Rest API.










      share|improve this question














      I want to add custom attribute to http://magento2/rest/V1/carts/mine/totals API response.



      I have done follwing way but it not working.



      extension_attributes.xml

      <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Api/etc/extension_attributes.xsd">
      <extension_attributes for="MagentoQuoteApiDataCartItemInterface">
      <attribute code="product_option" type="float" />
      </extension_attributes>
      </config>

      di.xml

      <type name="MagentoQuoteModelQuoteItem">
      <plugin name="cs_product_opt" type="NamespaceProductPluginModelCartCartTotalRepositoryPlugin" />
      </type>

      Plugin file

      <?php
      /**
      * Copyright 2016 aheadWorks. All rights reserved.
      * See LICENSE.txt for license details.
      */

      namespace NamespaceProductPluginModelCart;

      use MagentoQuoteApiDataTotalsExtensionInterface;
      use MagentoQuoteApiDataTotalsExtensionFactory;
      use MagentoQuoteApiDataCartItemExtensionFactory;
      use MagentoQuoteApiDataTotalsInterface;
      use MagentoQuoteApiCartRepositoryInterface;
      use MagentoQuoteModelCartCartTotalRepository as TotalRepository;
      use MagentoQuoteModelQuote;

      /**
      * Class AheadworksStoreCreditPluginModelCartCartTotalRepositoryPlugin
      */
      class CartTotalRepositoryPlugin

      /**
      * @var CartRepositoryInterface
      */
      private $quoteRepository;

      /**
      * @var CartItemExtensionFactory
      */
      private $totalsExtensionFactory;

      /**
      * @param CartRepositoryInterface $quoteRepository
      * @param CartItemExtensionFactory $totalsExtensionFactory
      */
      public function __construct(
      CartRepositoryInterface $quoteRepository,
      CartItemExtensionFactory $totalsExtensionFactory
      )
      $this->quoteRepository = $quoteRepository;
      $this->totalsExtensionFactory = $totalsExtensionFactory;


      /**
      * Apply extension attributes to totals
      *
      * @param TotalRepository $subject
      * @param Closure $proceed
      * @param int $cartId
      * @return TotalsInterface
      * @SuppressWarnings(PHPMD.UnusedFormalParameter)
      */
      public function aroundGet(TotalRepository $subject, Closure $proceed, $cartId)

      /** @var TotalsInterface $totals */
      $totals = $proceed($cartId);

      /** @var MagentoQuoteApiDataTotalsExtensionInterface $extensionAttributes */
      $extensionAttributes = $totals->getExtensionAttributes()
      ? $totals->getExtensionAttributes()
      : $this->totalsExtensionFactory->create();

      /** @var Quote $quote */
      $quote = $this->quoteRepository->getActive($cartId);

      $extensionAttributes->setProductOption(1.11);
      $totals->setExtensionAttributes($extensionAttributes);
      return $totals;




      anyone have idea how to add custom attribute to Quote Item Rest API.







      magento2 api rest-api






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 21 '18 at 6:01









      Niranjan GondaliyaNiranjan Gondaliya

      1739




      1739





      bumped to the homepage by Community 8 mins ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







      bumped to the homepage by Community 8 mins ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.






















          1 Answer
          1






          active

          oldest

          votes


















          0














          To add new attribute on cart item. you need to consume V1/carts/mine service.



          CartRepositoryPlugin.php



          <?php
          /**
          * Copyright 2016 aheadWorks. All rights reserved.
          * See LICENSE.txt for license details.
          */

          namespace NamespaceProductPluginModelCart;

          use MagentoQuoteApi;
          use MagentoQuoteApiCartRepositoryInterface;
          use MagentoQuoteApiCartTotalRepositoryInterface;
          use MagentoCatalogHelperProductConfigurationPool;
          use MagentoFrameworkApiDataObjectHelper;
          use MagentoFrameworkApiExtensibleDataInterface;
          use MagentoQuoteModelCartTotalsItemConverter;
          use MagentoQuoteApiCouponManagementInterface;
          use MagentoQuoteModelCartTotalsConverter;
          use MagentoQuoteApiDataCartItemExtensionFactory;
          use MagentoQuoteModelCartCartTotalRepository as TotalRepository;

          /**
          * Class AheadworksStoreCreditPluginModelCartCartTotalRepositoryPlugin
          */
          class CartRepositoryPlugin

          /**
          * Cart totals factory.
          *
          * @var ApiDataTotalsInterfaceFactory
          */
          private $totalsFactory;

          /**
          * Quote repository.
          *
          * @var MagentoQuoteApiCartRepositoryInterface
          */
          private $quoteRepository;

          /**
          * @var MagentoFrameworkApiDataObjectHelper
          */
          private $dataObjectHelper;

          /**
          * @var ConfigurationPool
          */
          private $itemConverter;

          /**
          * @var CouponManagementInterface
          */
          protected $couponService;

          /**
          * @var TotalsConverter
          */
          protected $totalsConverter;

          /**
          * @param ApiDataTotalsInterfaceFactory $totalsFactory
          * @param CartRepositoryInterface $quoteRepository
          * @param DataObjectHelper $dataObjectHelper
          * @param CouponManagementInterface $couponService
          * @param TotalsConverter $totalsConverter
          * @param ItemConverter $converter
          */
          public function __construct(
          ApiDataTotalsInterfaceFactory $totalsFactory,
          CartRepositoryInterface $quoteRepository,
          DataObjectHelper $dataObjectHelper,
          CouponManagementInterface $couponService,
          TotalsConverter $totalsConverter,
          CartItemExtensionFactory $cartItemInterfaceFactory,
          ItemConverter $converter
          )
          $this->totalsFactory = $totalsFactory;
          $this->quoteRepository = $quoteRepository;
          $this->dataObjectHelper = $dataObjectHelper;
          $this->couponService = $couponService;
          $this->totalsConverter = $totalsConverter;
          $this->cartItemInterfaceFactory = $cartItemInterfaceFactory;
          $this->itemConverter = $converter;


          /**
          * Apply extension attributes to totals
          *
          * @param TotalRepository $subject
          * @param Closure $proceed
          * @param int $cartId
          * @return TotalsInterface
          * @SuppressWarnings(PHPMD.UnusedFormalParameter)
          */

          public function aroundGet(TotalRepository $subject, Closure $proceed, $cartId)

          /** @var MagentoQuoteModelQuote $quote */
          $quote = $this->quoteRepository->getActive($cartId);
          if ($quote->isVirtual())
          $addressTotalsData = $quote->getBillingAddress()->getData();
          $addressTotals = $quote->getBillingAddress()->getTotals();
          else
          $addressTotalsData = $quote->getShippingAddress()->getData();
          $addressTotals = $quote->getShippingAddress()->getTotals();

          unset($addressTotalsData[ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY]);

          /** @var MagentoQuoteApiDataTotalsInterface $quoteTotals */
          $quoteTotals = $this->totalsFactory->create();
          $this->dataObjectHelper->populateWithArray(
          $quoteTotals,
          $addressTotalsData,
          MagentoQuoteApiDataTotalsInterface::class
          );
          $items = [];
          foreach ($quote->getAllVisibleItems() as $index => $item)
          $cartItemExtensionAttributes = $item->getExtensionAttributes();
          if($cartItemExtensionAttributes == null)
          $cartItemExtensionAttributes = $this->cartItemInterfaceFactory->create();
          $cartItemExtensionAttributes->setProductOption('Product Option Check');
          $item->setExtensionAttributes($cartItemExtensionAttributes);
          $item->save();

          $items[$index] = $this->itemConverter->modelToDataObject($item);


          $calculatedTotals = $this->totalsConverter->process($addressTotals);
          $quoteTotals->setTotalSegments($calculatedTotals);
          $amount = $quoteTotals->getGrandTotal() - $quoteTotals->getTaxAmount();
          $amount = $amount > 0 ? $amount : 0;
          $quoteTotals->setCouponCode($this->couponService->get($cartId));
          $quoteTotals->setGrandTotal($amount);
          $quoteTotals->setItems($items);
          $quoteTotals->setItemsQty($quote->getItemsQty());
          $quoteTotals->setBaseCurrencyCode($quote->getBaseCurrencyCode());
          $quoteTotals->setQuoteCurrencyCode($quote->getQuoteCurrencyCode());
          return $quoteTotals;




          extension_attributes.xml



           <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Api/etc/extension_attributes.xsd">
          <extension_attributes for="MagentoQuoteApiDataCartItemInterface">
          <attribute code="product_option" type="string" />
          </extension_attributes>




          di.xml



           <type name="MagentoQuoteModelCartCartTotalRepository">
          <plugin name="cp_product_opt" type="CommercepunditProductPluginModelCartCartRepositoryPlugin" />
          </type>


          I hope it'll work for you. Let me know if you need further help.






          share|improve this answer

























          • no i no needed in total i want this in Quote Item.

            – Niranjan Gondaliya
            Nov 21 '18 at 6:32











          • if you need this in cart item then you need to do create your plugin on cart repository as total api does not return item data

            – Ramkishan Suthar
            Nov 21 '18 at 6:57











          • Please check updated answer.

            – Ramkishan Suthar
            Nov 21 '18 at 7:05











          • ok Let me implement

            – Niranjan Gondaliya
            Nov 21 '18 at 7:13











          • Call to undefined method Magento\Quote\Model\QuoteRepository\Interceptor::getItems()

            – Niranjan Gondaliya
            Nov 21 '18 at 7:32











          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "479"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f250744%2fmagento-2-how-to-add-custom-attribute-to-quote-item-rest-api%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          To add new attribute on cart item. you need to consume V1/carts/mine service.



          CartRepositoryPlugin.php



          <?php
          /**
          * Copyright 2016 aheadWorks. All rights reserved.
          * See LICENSE.txt for license details.
          */

          namespace NamespaceProductPluginModelCart;

          use MagentoQuoteApi;
          use MagentoQuoteApiCartRepositoryInterface;
          use MagentoQuoteApiCartTotalRepositoryInterface;
          use MagentoCatalogHelperProductConfigurationPool;
          use MagentoFrameworkApiDataObjectHelper;
          use MagentoFrameworkApiExtensibleDataInterface;
          use MagentoQuoteModelCartTotalsItemConverter;
          use MagentoQuoteApiCouponManagementInterface;
          use MagentoQuoteModelCartTotalsConverter;
          use MagentoQuoteApiDataCartItemExtensionFactory;
          use MagentoQuoteModelCartCartTotalRepository as TotalRepository;

          /**
          * Class AheadworksStoreCreditPluginModelCartCartTotalRepositoryPlugin
          */
          class CartRepositoryPlugin

          /**
          * Cart totals factory.
          *
          * @var ApiDataTotalsInterfaceFactory
          */
          private $totalsFactory;

          /**
          * Quote repository.
          *
          * @var MagentoQuoteApiCartRepositoryInterface
          */
          private $quoteRepository;

          /**
          * @var MagentoFrameworkApiDataObjectHelper
          */
          private $dataObjectHelper;

          /**
          * @var ConfigurationPool
          */
          private $itemConverter;

          /**
          * @var CouponManagementInterface
          */
          protected $couponService;

          /**
          * @var TotalsConverter
          */
          protected $totalsConverter;

          /**
          * @param ApiDataTotalsInterfaceFactory $totalsFactory
          * @param CartRepositoryInterface $quoteRepository
          * @param DataObjectHelper $dataObjectHelper
          * @param CouponManagementInterface $couponService
          * @param TotalsConverter $totalsConverter
          * @param ItemConverter $converter
          */
          public function __construct(
          ApiDataTotalsInterfaceFactory $totalsFactory,
          CartRepositoryInterface $quoteRepository,
          DataObjectHelper $dataObjectHelper,
          CouponManagementInterface $couponService,
          TotalsConverter $totalsConverter,
          CartItemExtensionFactory $cartItemInterfaceFactory,
          ItemConverter $converter
          )
          $this->totalsFactory = $totalsFactory;
          $this->quoteRepository = $quoteRepository;
          $this->dataObjectHelper = $dataObjectHelper;
          $this->couponService = $couponService;
          $this->totalsConverter = $totalsConverter;
          $this->cartItemInterfaceFactory = $cartItemInterfaceFactory;
          $this->itemConverter = $converter;


          /**
          * Apply extension attributes to totals
          *
          * @param TotalRepository $subject
          * @param Closure $proceed
          * @param int $cartId
          * @return TotalsInterface
          * @SuppressWarnings(PHPMD.UnusedFormalParameter)
          */

          public function aroundGet(TotalRepository $subject, Closure $proceed, $cartId)

          /** @var MagentoQuoteModelQuote $quote */
          $quote = $this->quoteRepository->getActive($cartId);
          if ($quote->isVirtual())
          $addressTotalsData = $quote->getBillingAddress()->getData();
          $addressTotals = $quote->getBillingAddress()->getTotals();
          else
          $addressTotalsData = $quote->getShippingAddress()->getData();
          $addressTotals = $quote->getShippingAddress()->getTotals();

          unset($addressTotalsData[ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY]);

          /** @var MagentoQuoteApiDataTotalsInterface $quoteTotals */
          $quoteTotals = $this->totalsFactory->create();
          $this->dataObjectHelper->populateWithArray(
          $quoteTotals,
          $addressTotalsData,
          MagentoQuoteApiDataTotalsInterface::class
          );
          $items = [];
          foreach ($quote->getAllVisibleItems() as $index => $item)
          $cartItemExtensionAttributes = $item->getExtensionAttributes();
          if($cartItemExtensionAttributes == null)
          $cartItemExtensionAttributes = $this->cartItemInterfaceFactory->create();
          $cartItemExtensionAttributes->setProductOption('Product Option Check');
          $item->setExtensionAttributes($cartItemExtensionAttributes);
          $item->save();

          $items[$index] = $this->itemConverter->modelToDataObject($item);


          $calculatedTotals = $this->totalsConverter->process($addressTotals);
          $quoteTotals->setTotalSegments($calculatedTotals);
          $amount = $quoteTotals->getGrandTotal() - $quoteTotals->getTaxAmount();
          $amount = $amount > 0 ? $amount : 0;
          $quoteTotals->setCouponCode($this->couponService->get($cartId));
          $quoteTotals->setGrandTotal($amount);
          $quoteTotals->setItems($items);
          $quoteTotals->setItemsQty($quote->getItemsQty());
          $quoteTotals->setBaseCurrencyCode($quote->getBaseCurrencyCode());
          $quoteTotals->setQuoteCurrencyCode($quote->getQuoteCurrencyCode());
          return $quoteTotals;




          extension_attributes.xml



           <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Api/etc/extension_attributes.xsd">
          <extension_attributes for="MagentoQuoteApiDataCartItemInterface">
          <attribute code="product_option" type="string" />
          </extension_attributes>




          di.xml



           <type name="MagentoQuoteModelCartCartTotalRepository">
          <plugin name="cp_product_opt" type="CommercepunditProductPluginModelCartCartRepositoryPlugin" />
          </type>


          I hope it'll work for you. Let me know if you need further help.






          share|improve this answer

























          • no i no needed in total i want this in Quote Item.

            – Niranjan Gondaliya
            Nov 21 '18 at 6:32











          • if you need this in cart item then you need to do create your plugin on cart repository as total api does not return item data

            – Ramkishan Suthar
            Nov 21 '18 at 6:57











          • Please check updated answer.

            – Ramkishan Suthar
            Nov 21 '18 at 7:05











          • ok Let me implement

            – Niranjan Gondaliya
            Nov 21 '18 at 7:13











          • Call to undefined method Magento\Quote\Model\QuoteRepository\Interceptor::getItems()

            – Niranjan Gondaliya
            Nov 21 '18 at 7:32















          0














          To add new attribute on cart item. you need to consume V1/carts/mine service.



          CartRepositoryPlugin.php



          <?php
          /**
          * Copyright 2016 aheadWorks. All rights reserved.
          * See LICENSE.txt for license details.
          */

          namespace NamespaceProductPluginModelCart;

          use MagentoQuoteApi;
          use MagentoQuoteApiCartRepositoryInterface;
          use MagentoQuoteApiCartTotalRepositoryInterface;
          use MagentoCatalogHelperProductConfigurationPool;
          use MagentoFrameworkApiDataObjectHelper;
          use MagentoFrameworkApiExtensibleDataInterface;
          use MagentoQuoteModelCartTotalsItemConverter;
          use MagentoQuoteApiCouponManagementInterface;
          use MagentoQuoteModelCartTotalsConverter;
          use MagentoQuoteApiDataCartItemExtensionFactory;
          use MagentoQuoteModelCartCartTotalRepository as TotalRepository;

          /**
          * Class AheadworksStoreCreditPluginModelCartCartTotalRepositoryPlugin
          */
          class CartRepositoryPlugin

          /**
          * Cart totals factory.
          *
          * @var ApiDataTotalsInterfaceFactory
          */
          private $totalsFactory;

          /**
          * Quote repository.
          *
          * @var MagentoQuoteApiCartRepositoryInterface
          */
          private $quoteRepository;

          /**
          * @var MagentoFrameworkApiDataObjectHelper
          */
          private $dataObjectHelper;

          /**
          * @var ConfigurationPool
          */
          private $itemConverter;

          /**
          * @var CouponManagementInterface
          */
          protected $couponService;

          /**
          * @var TotalsConverter
          */
          protected $totalsConverter;

          /**
          * @param ApiDataTotalsInterfaceFactory $totalsFactory
          * @param CartRepositoryInterface $quoteRepository
          * @param DataObjectHelper $dataObjectHelper
          * @param CouponManagementInterface $couponService
          * @param TotalsConverter $totalsConverter
          * @param ItemConverter $converter
          */
          public function __construct(
          ApiDataTotalsInterfaceFactory $totalsFactory,
          CartRepositoryInterface $quoteRepository,
          DataObjectHelper $dataObjectHelper,
          CouponManagementInterface $couponService,
          TotalsConverter $totalsConverter,
          CartItemExtensionFactory $cartItemInterfaceFactory,
          ItemConverter $converter
          )
          $this->totalsFactory = $totalsFactory;
          $this->quoteRepository = $quoteRepository;
          $this->dataObjectHelper = $dataObjectHelper;
          $this->couponService = $couponService;
          $this->totalsConverter = $totalsConverter;
          $this->cartItemInterfaceFactory = $cartItemInterfaceFactory;
          $this->itemConverter = $converter;


          /**
          * Apply extension attributes to totals
          *
          * @param TotalRepository $subject
          * @param Closure $proceed
          * @param int $cartId
          * @return TotalsInterface
          * @SuppressWarnings(PHPMD.UnusedFormalParameter)
          */

          public function aroundGet(TotalRepository $subject, Closure $proceed, $cartId)

          /** @var MagentoQuoteModelQuote $quote */
          $quote = $this->quoteRepository->getActive($cartId);
          if ($quote->isVirtual())
          $addressTotalsData = $quote->getBillingAddress()->getData();
          $addressTotals = $quote->getBillingAddress()->getTotals();
          else
          $addressTotalsData = $quote->getShippingAddress()->getData();
          $addressTotals = $quote->getShippingAddress()->getTotals();

          unset($addressTotalsData[ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY]);

          /** @var MagentoQuoteApiDataTotalsInterface $quoteTotals */
          $quoteTotals = $this->totalsFactory->create();
          $this->dataObjectHelper->populateWithArray(
          $quoteTotals,
          $addressTotalsData,
          MagentoQuoteApiDataTotalsInterface::class
          );
          $items = [];
          foreach ($quote->getAllVisibleItems() as $index => $item)
          $cartItemExtensionAttributes = $item->getExtensionAttributes();
          if($cartItemExtensionAttributes == null)
          $cartItemExtensionAttributes = $this->cartItemInterfaceFactory->create();
          $cartItemExtensionAttributes->setProductOption('Product Option Check');
          $item->setExtensionAttributes($cartItemExtensionAttributes);
          $item->save();

          $items[$index] = $this->itemConverter->modelToDataObject($item);


          $calculatedTotals = $this->totalsConverter->process($addressTotals);
          $quoteTotals->setTotalSegments($calculatedTotals);
          $amount = $quoteTotals->getGrandTotal() - $quoteTotals->getTaxAmount();
          $amount = $amount > 0 ? $amount : 0;
          $quoteTotals->setCouponCode($this->couponService->get($cartId));
          $quoteTotals->setGrandTotal($amount);
          $quoteTotals->setItems($items);
          $quoteTotals->setItemsQty($quote->getItemsQty());
          $quoteTotals->setBaseCurrencyCode($quote->getBaseCurrencyCode());
          $quoteTotals->setQuoteCurrencyCode($quote->getQuoteCurrencyCode());
          return $quoteTotals;




          extension_attributes.xml



           <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Api/etc/extension_attributes.xsd">
          <extension_attributes for="MagentoQuoteApiDataCartItemInterface">
          <attribute code="product_option" type="string" />
          </extension_attributes>




          di.xml



           <type name="MagentoQuoteModelCartCartTotalRepository">
          <plugin name="cp_product_opt" type="CommercepunditProductPluginModelCartCartRepositoryPlugin" />
          </type>


          I hope it'll work for you. Let me know if you need further help.






          share|improve this answer

























          • no i no needed in total i want this in Quote Item.

            – Niranjan Gondaliya
            Nov 21 '18 at 6:32











          • if you need this in cart item then you need to do create your plugin on cart repository as total api does not return item data

            – Ramkishan Suthar
            Nov 21 '18 at 6:57











          • Please check updated answer.

            – Ramkishan Suthar
            Nov 21 '18 at 7:05











          • ok Let me implement

            – Niranjan Gondaliya
            Nov 21 '18 at 7:13











          • Call to undefined method Magento\Quote\Model\QuoteRepository\Interceptor::getItems()

            – Niranjan Gondaliya
            Nov 21 '18 at 7:32













          0












          0








          0







          To add new attribute on cart item. you need to consume V1/carts/mine service.



          CartRepositoryPlugin.php



          <?php
          /**
          * Copyright 2016 aheadWorks. All rights reserved.
          * See LICENSE.txt for license details.
          */

          namespace NamespaceProductPluginModelCart;

          use MagentoQuoteApi;
          use MagentoQuoteApiCartRepositoryInterface;
          use MagentoQuoteApiCartTotalRepositoryInterface;
          use MagentoCatalogHelperProductConfigurationPool;
          use MagentoFrameworkApiDataObjectHelper;
          use MagentoFrameworkApiExtensibleDataInterface;
          use MagentoQuoteModelCartTotalsItemConverter;
          use MagentoQuoteApiCouponManagementInterface;
          use MagentoQuoteModelCartTotalsConverter;
          use MagentoQuoteApiDataCartItemExtensionFactory;
          use MagentoQuoteModelCartCartTotalRepository as TotalRepository;

          /**
          * Class AheadworksStoreCreditPluginModelCartCartTotalRepositoryPlugin
          */
          class CartRepositoryPlugin

          /**
          * Cart totals factory.
          *
          * @var ApiDataTotalsInterfaceFactory
          */
          private $totalsFactory;

          /**
          * Quote repository.
          *
          * @var MagentoQuoteApiCartRepositoryInterface
          */
          private $quoteRepository;

          /**
          * @var MagentoFrameworkApiDataObjectHelper
          */
          private $dataObjectHelper;

          /**
          * @var ConfigurationPool
          */
          private $itemConverter;

          /**
          * @var CouponManagementInterface
          */
          protected $couponService;

          /**
          * @var TotalsConverter
          */
          protected $totalsConverter;

          /**
          * @param ApiDataTotalsInterfaceFactory $totalsFactory
          * @param CartRepositoryInterface $quoteRepository
          * @param DataObjectHelper $dataObjectHelper
          * @param CouponManagementInterface $couponService
          * @param TotalsConverter $totalsConverter
          * @param ItemConverter $converter
          */
          public function __construct(
          ApiDataTotalsInterfaceFactory $totalsFactory,
          CartRepositoryInterface $quoteRepository,
          DataObjectHelper $dataObjectHelper,
          CouponManagementInterface $couponService,
          TotalsConverter $totalsConverter,
          CartItemExtensionFactory $cartItemInterfaceFactory,
          ItemConverter $converter
          )
          $this->totalsFactory = $totalsFactory;
          $this->quoteRepository = $quoteRepository;
          $this->dataObjectHelper = $dataObjectHelper;
          $this->couponService = $couponService;
          $this->totalsConverter = $totalsConverter;
          $this->cartItemInterfaceFactory = $cartItemInterfaceFactory;
          $this->itemConverter = $converter;


          /**
          * Apply extension attributes to totals
          *
          * @param TotalRepository $subject
          * @param Closure $proceed
          * @param int $cartId
          * @return TotalsInterface
          * @SuppressWarnings(PHPMD.UnusedFormalParameter)
          */

          public function aroundGet(TotalRepository $subject, Closure $proceed, $cartId)

          /** @var MagentoQuoteModelQuote $quote */
          $quote = $this->quoteRepository->getActive($cartId);
          if ($quote->isVirtual())
          $addressTotalsData = $quote->getBillingAddress()->getData();
          $addressTotals = $quote->getBillingAddress()->getTotals();
          else
          $addressTotalsData = $quote->getShippingAddress()->getData();
          $addressTotals = $quote->getShippingAddress()->getTotals();

          unset($addressTotalsData[ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY]);

          /** @var MagentoQuoteApiDataTotalsInterface $quoteTotals */
          $quoteTotals = $this->totalsFactory->create();
          $this->dataObjectHelper->populateWithArray(
          $quoteTotals,
          $addressTotalsData,
          MagentoQuoteApiDataTotalsInterface::class
          );
          $items = [];
          foreach ($quote->getAllVisibleItems() as $index => $item)
          $cartItemExtensionAttributes = $item->getExtensionAttributes();
          if($cartItemExtensionAttributes == null)
          $cartItemExtensionAttributes = $this->cartItemInterfaceFactory->create();
          $cartItemExtensionAttributes->setProductOption('Product Option Check');
          $item->setExtensionAttributes($cartItemExtensionAttributes);
          $item->save();

          $items[$index] = $this->itemConverter->modelToDataObject($item);


          $calculatedTotals = $this->totalsConverter->process($addressTotals);
          $quoteTotals->setTotalSegments($calculatedTotals);
          $amount = $quoteTotals->getGrandTotal() - $quoteTotals->getTaxAmount();
          $amount = $amount > 0 ? $amount : 0;
          $quoteTotals->setCouponCode($this->couponService->get($cartId));
          $quoteTotals->setGrandTotal($amount);
          $quoteTotals->setItems($items);
          $quoteTotals->setItemsQty($quote->getItemsQty());
          $quoteTotals->setBaseCurrencyCode($quote->getBaseCurrencyCode());
          $quoteTotals->setQuoteCurrencyCode($quote->getQuoteCurrencyCode());
          return $quoteTotals;




          extension_attributes.xml



           <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Api/etc/extension_attributes.xsd">
          <extension_attributes for="MagentoQuoteApiDataCartItemInterface">
          <attribute code="product_option" type="string" />
          </extension_attributes>




          di.xml



           <type name="MagentoQuoteModelCartCartTotalRepository">
          <plugin name="cp_product_opt" type="CommercepunditProductPluginModelCartCartRepositoryPlugin" />
          </type>


          I hope it'll work for you. Let me know if you need further help.






          share|improve this answer















          To add new attribute on cart item. you need to consume V1/carts/mine service.



          CartRepositoryPlugin.php



          <?php
          /**
          * Copyright 2016 aheadWorks. All rights reserved.
          * See LICENSE.txt for license details.
          */

          namespace NamespaceProductPluginModelCart;

          use MagentoQuoteApi;
          use MagentoQuoteApiCartRepositoryInterface;
          use MagentoQuoteApiCartTotalRepositoryInterface;
          use MagentoCatalogHelperProductConfigurationPool;
          use MagentoFrameworkApiDataObjectHelper;
          use MagentoFrameworkApiExtensibleDataInterface;
          use MagentoQuoteModelCartTotalsItemConverter;
          use MagentoQuoteApiCouponManagementInterface;
          use MagentoQuoteModelCartTotalsConverter;
          use MagentoQuoteApiDataCartItemExtensionFactory;
          use MagentoQuoteModelCartCartTotalRepository as TotalRepository;

          /**
          * Class AheadworksStoreCreditPluginModelCartCartTotalRepositoryPlugin
          */
          class CartRepositoryPlugin

          /**
          * Cart totals factory.
          *
          * @var ApiDataTotalsInterfaceFactory
          */
          private $totalsFactory;

          /**
          * Quote repository.
          *
          * @var MagentoQuoteApiCartRepositoryInterface
          */
          private $quoteRepository;

          /**
          * @var MagentoFrameworkApiDataObjectHelper
          */
          private $dataObjectHelper;

          /**
          * @var ConfigurationPool
          */
          private $itemConverter;

          /**
          * @var CouponManagementInterface
          */
          protected $couponService;

          /**
          * @var TotalsConverter
          */
          protected $totalsConverter;

          /**
          * @param ApiDataTotalsInterfaceFactory $totalsFactory
          * @param CartRepositoryInterface $quoteRepository
          * @param DataObjectHelper $dataObjectHelper
          * @param CouponManagementInterface $couponService
          * @param TotalsConverter $totalsConverter
          * @param ItemConverter $converter
          */
          public function __construct(
          ApiDataTotalsInterfaceFactory $totalsFactory,
          CartRepositoryInterface $quoteRepository,
          DataObjectHelper $dataObjectHelper,
          CouponManagementInterface $couponService,
          TotalsConverter $totalsConverter,
          CartItemExtensionFactory $cartItemInterfaceFactory,
          ItemConverter $converter
          )
          $this->totalsFactory = $totalsFactory;
          $this->quoteRepository = $quoteRepository;
          $this->dataObjectHelper = $dataObjectHelper;
          $this->couponService = $couponService;
          $this->totalsConverter = $totalsConverter;
          $this->cartItemInterfaceFactory = $cartItemInterfaceFactory;
          $this->itemConverter = $converter;


          /**
          * Apply extension attributes to totals
          *
          * @param TotalRepository $subject
          * @param Closure $proceed
          * @param int $cartId
          * @return TotalsInterface
          * @SuppressWarnings(PHPMD.UnusedFormalParameter)
          */

          public function aroundGet(TotalRepository $subject, Closure $proceed, $cartId)

          /** @var MagentoQuoteModelQuote $quote */
          $quote = $this->quoteRepository->getActive($cartId);
          if ($quote->isVirtual())
          $addressTotalsData = $quote->getBillingAddress()->getData();
          $addressTotals = $quote->getBillingAddress()->getTotals();
          else
          $addressTotalsData = $quote->getShippingAddress()->getData();
          $addressTotals = $quote->getShippingAddress()->getTotals();

          unset($addressTotalsData[ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY]);

          /** @var MagentoQuoteApiDataTotalsInterface $quoteTotals */
          $quoteTotals = $this->totalsFactory->create();
          $this->dataObjectHelper->populateWithArray(
          $quoteTotals,
          $addressTotalsData,
          MagentoQuoteApiDataTotalsInterface::class
          );
          $items = [];
          foreach ($quote->getAllVisibleItems() as $index => $item)
          $cartItemExtensionAttributes = $item->getExtensionAttributes();
          if($cartItemExtensionAttributes == null)
          $cartItemExtensionAttributes = $this->cartItemInterfaceFactory->create();
          $cartItemExtensionAttributes->setProductOption('Product Option Check');
          $item->setExtensionAttributes($cartItemExtensionAttributes);
          $item->save();

          $items[$index] = $this->itemConverter->modelToDataObject($item);


          $calculatedTotals = $this->totalsConverter->process($addressTotals);
          $quoteTotals->setTotalSegments($calculatedTotals);
          $amount = $quoteTotals->getGrandTotal() - $quoteTotals->getTaxAmount();
          $amount = $amount > 0 ? $amount : 0;
          $quoteTotals->setCouponCode($this->couponService->get($cartId));
          $quoteTotals->setGrandTotal($amount);
          $quoteTotals->setItems($items);
          $quoteTotals->setItemsQty($quote->getItemsQty());
          $quoteTotals->setBaseCurrencyCode($quote->getBaseCurrencyCode());
          $quoteTotals->setQuoteCurrencyCode($quote->getQuoteCurrencyCode());
          return $quoteTotals;




          extension_attributes.xml



           <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Api/etc/extension_attributes.xsd">
          <extension_attributes for="MagentoQuoteApiDataCartItemInterface">
          <attribute code="product_option" type="string" />
          </extension_attributes>




          di.xml



           <type name="MagentoQuoteModelCartCartTotalRepository">
          <plugin name="cp_product_opt" type="CommercepunditProductPluginModelCartCartRepositoryPlugin" />
          </type>


          I hope it'll work for you. Let me know if you need further help.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 22 '18 at 6:07

























          answered Nov 21 '18 at 6:19









          Ramkishan SutharRamkishan Suthar

          2,29221435




          2,29221435












          • no i no needed in total i want this in Quote Item.

            – Niranjan Gondaliya
            Nov 21 '18 at 6:32











          • if you need this in cart item then you need to do create your plugin on cart repository as total api does not return item data

            – Ramkishan Suthar
            Nov 21 '18 at 6:57











          • Please check updated answer.

            – Ramkishan Suthar
            Nov 21 '18 at 7:05











          • ok Let me implement

            – Niranjan Gondaliya
            Nov 21 '18 at 7:13











          • Call to undefined method Magento\Quote\Model\QuoteRepository\Interceptor::getItems()

            – Niranjan Gondaliya
            Nov 21 '18 at 7:32

















          • no i no needed in total i want this in Quote Item.

            – Niranjan Gondaliya
            Nov 21 '18 at 6:32











          • if you need this in cart item then you need to do create your plugin on cart repository as total api does not return item data

            – Ramkishan Suthar
            Nov 21 '18 at 6:57











          • Please check updated answer.

            – Ramkishan Suthar
            Nov 21 '18 at 7:05











          • ok Let me implement

            – Niranjan Gondaliya
            Nov 21 '18 at 7:13











          • Call to undefined method Magento\Quote\Model\QuoteRepository\Interceptor::getItems()

            – Niranjan Gondaliya
            Nov 21 '18 at 7:32
















          no i no needed in total i want this in Quote Item.

          – Niranjan Gondaliya
          Nov 21 '18 at 6:32





          no i no needed in total i want this in Quote Item.

          – Niranjan Gondaliya
          Nov 21 '18 at 6:32













          if you need this in cart item then you need to do create your plugin on cart repository as total api does not return item data

          – Ramkishan Suthar
          Nov 21 '18 at 6:57





          if you need this in cart item then you need to do create your plugin on cart repository as total api does not return item data

          – Ramkishan Suthar
          Nov 21 '18 at 6:57













          Please check updated answer.

          – Ramkishan Suthar
          Nov 21 '18 at 7:05





          Please check updated answer.

          – Ramkishan Suthar
          Nov 21 '18 at 7:05













          ok Let me implement

          – Niranjan Gondaliya
          Nov 21 '18 at 7:13





          ok Let me implement

          – Niranjan Gondaliya
          Nov 21 '18 at 7:13













          Call to undefined method Magento\Quote\Model\QuoteRepository\Interceptor::getItems()

          – Niranjan Gondaliya
          Nov 21 '18 at 7:32





          Call to undefined method Magento\Quote\Model\QuoteRepository\Interceptor::getItems()

          – Niranjan Gondaliya
          Nov 21 '18 at 7:32

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Magento Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f250744%2fmagento-2-how-to-add-custom-attribute-to-quote-item-rest-api%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Magento 2 duplicate PHPSESSID cookie when using session_start() in custom php scriptMagento 2: User cant logged in into to account page, no error showing!Magento duplicate on subdomainGrabbing storeview from cookie (after using language selector)How do I run php custom script on magento2Magento 2: Include PHP script in headerSession lock after using Cm_RedisSessionscript php to update stockMagento set cookie popupMagento 2 session id cookie - where to find it?How to import Configurable product from csv with custom attributes using php scriptMagento 2 run custom PHP script

          Can not update quote_id field of “quote_item” table magento 2Magento 2.1 - We can't remove the item. (Shopping Cart doesnt allow us to remove items before becomes empty)Add value for custom quote item attribute using REST apiREST API endpoint v1/carts/cartId/items always returns error messageCorrect way to save entries to databaseHow to remove all associated quote objects of a customer completelyMagento 2 - Save value from custom input field to quote_itemGet quote_item data using quote id and product id filter in Magento 2How to set additional data to quote_item table from controller in Magento 2?What is the purpose of additional_data column in quote_item table in magento2Set Custom Price to Quote item magento2 from controller

          How to solve knockout JS error in Magento 2 Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?(Magento2) knockout.js:3012 Uncaught ReferenceError: Unable to process bindingUnable to process binding Knockout.js magento 2Cannot read property `scopeLabel` of undefined on Product Detail PageCan't get Customer Data on frontend in Magento 2Magento2 Order Summary - unable to process bindingKO templates are not loading in Magento 2.1 applicationgetting knockout js error magento 2Product grid not load -— Unable to process binding Knockout.js magento 2Product form not loaded in magento2Uncaught ReferenceError: Unable to process binding “if: function()return (isShowLegend()) ” magento 2