Below is my code:
namespace Ves\Productlist\Controller\Cart;
use Magento\Quote\Model\QuoteRepository;
class CartUpdate extends \Magento\Framework\App\Action\Action
{
protected $quoteRepository;
public function __construct(
\Magento\Quote\Api\CartRepositoryInterface $quoteRepository
) {
$this->quoteRepository = $quoteRepository;
}
public function execute()
{
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$cart = $objectManager->get('\Magento\Checkout\Model\Cart');
echo $cartId=$cart->getQuote()->getId();
$itemId = 720;
$itemQty = 1;
$quote = $this->quoteRepository->getActive($cartId);
$cartitems->setquoteId($cartId);
$cartitems->setitemId($itemId);
$cartitems->setqty($itemQty);
$quoteItems[] = $cartitems;
$quote->setItems($quoteItems);
$this->quoteRepository->save($quote);
$quote->collectTotals();
}
}