I am trying to upgrade a Magento 2 extension. When I run setup:upgrade,

I get the following error,

Upgrading data.. No such entity with cartId = 356670

How can I debug where exactly this error is happening? Is there any sort of log file created by setup:upgrade that will help me identify what SQL query is causing this error?

3 Answers 3


Upgrading data.. No such entity with cartId = 356670.

Please check in your Database in cart table there was a record with id 356670, and many other id there, this type of id is deleted but still in the database as record. So you can first delete it,it solved error..Many Thanks...


Try to run below SQL directly to DB.

UPDATE `store` SET store_id = 0 WHERE code='admin';
UPDATE `store_group` SET group_id = 0 WHERE name='Default';
UPDATE `store_website` SET website_id = 0 WHERE code='admin';
UPDATE `customer_group` SET customer_group_id = 0 WHERE customer_group_code='NOT LOGGED IN';

Make sure take backup !!

  • Already tried that, no go Feb 6, 2019 at 5:12

What Magento 2 version do you have ? Check this file

vendor/magento/module-quote//Model/QuoteRepository.php replace

 $quote = $this->loadQuote('load', 'cartId', $cartId, $sharedStoreIds);


    $quote = $this->loadQuote('loadByIdWithoutStore', 'cartId', $cartId, $sharedStoreIds);

It will look like something like :

public function get($cartId, array $sharedStoreIds = [])
    if (!isset($this->quotesById[$cartId])) {
        $quote = $this->loadQuote('loadByIdWithoutStore', 'cartId', $cartId, $sharedStoreIds);
        $this->quotesById[$cartId] = $quote;
    return $this->quotesById[$cartId];

Try again running the commands.

  • It's Magento 2.2.5 Feb 7, 2019 at 4:09

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.