Basically I am trying to update configurable product which has been successfully added to the shopping cart. I can see record of added configurable product item in my database quote, quote_item , quote_item_option tables after it has been added to my shopping cart. But when I update item it throws We can't find the quote item. Though quote item is present in the above mentioned tables. I am currently debugging app\code\Company\Checkout\Controller\Cart\UpdateItemOptions.php. I can see echo $item->getProductId(); of added configurable product present in shoppingcart. Can anyone please guide me how to debug and solve this issue? I really want to learn how magento cart module works it would be really helpful. I also checked \var\log\debug.log but no errors or warnings.

 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.

namespace Company\Checkout\Controller\Cart;

use Magento\Checkout\Model\Cart as CustomerCart;
use Company\Core\Helper\CustomerHelper;
use Company\PricingAPI\Helper\PricingAPIHelper;
use Company\Core\Helper\QuoteHelper;
use \Company\Core\Helper\UploadHelper;
use \Company\Core\Helper\CookieHelper;

class UpdateItemOptions extends \Magento\Checkout\Controller\Cart\UpdateItemOptions
    protected $customerHelper;
    protected $pricingAPIHelper;
    protected $quoteHelper;
    protected $uploadHelper;
    protected $cookieHelper;

    public function __construct(
        \Magento\Framework\App\Action\Context $context,
        \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
        \Magento\Checkout\Model\Session $checkoutSession,
        \Magento\Store\Model\StoreManagerInterface $storeManager,
        \Magento\Framework\Data\Form\FormKey\Validator $formKeyValidator,
        CustomerCart $cart,
        CustomerHelper $customerHelper,
        PricingAPIHelper $pricingAPIHelper,
        QuoteHelper $quoteHelper,
        UploadHelper $uploadHelper,
        CookieHelper $cookieHelper
        $this->customerHelper = $customerHelper;
        $this->pricingAPIHelper = $pricingAPIHelper;
        $this->quoteHelper = $quoteHelper;
        $this->uploadHelper = $uploadHelper;
        $this->cookieHelper = $cookieHelper;
        parent::__construct($context, $scopeConfig, $checkoutSession, $storeManager, $formKeyValidator, $cart);

     * Update product configuration for a cart item
     * @return \Magento\Framework\Controller\Result\Redirect
     * @SuppressWarnings(PHPMD.CyclomaticComplexity)
     * @SuppressWarnings(PHPMD.NPathComplexity)
    public function execute()
        $id = (int)$this->getRequest()->getParam('id');
        $params = $this->getRequest()->getParams();

        if (!isset($params['options'])) 
            $params['options'] = [];

            if (isset($params['qty'])) 
                $filter = new \Zend_Filter_LocalizedToNormalized(
                    ['locale' => $this->_objectManager->get(
                $params['qty'] = $filter->filter($params['qty']);

            $quoteItem = $this->cart->getQuote()->getItemById($id);
            $productInfo = $this->cart->getQuote()->getItemsCollection();
          //$productInfo = $this->_cart->getQuote()->getAllItems(); /*****For All items *****/
            foreach ($productInfo as $item){
               echo $item->getProductId();
               echo'<br />';
            if (!$quoteItem) {
                throw new \Magento\Framework\Exception\LocalizedException(__('We can\'t find the quote item.'));

1 Answer 1


Note sure what is app\code\Company\Checkout\Controller\Cart\UpdateItemOptions.php - a preference, or observer, but possible reason is - the original controller vendor/magento/module-checkout/Controller/Cart/UpdateItemOptions.php:46 is actually depeting the old item and adding a new on this line: $item = $this->cart->updateItem($id, new \Magento\Framework\DataObject($params)); Thus when you are trying to receive an item by its ID ($this->getRequest()->getParam('id')) it can be already deleted here vendor/magento/module-quote/Model/Quote.php:1799

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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