Magento – Magento 2 : Order Edit Error “No such entity with cartId = 458”

entitiesmagento-2.1magento2multistore

When I am going to edit order then getting an error like above.

No such entity with cartId = 458.

Magento 2 No such entity with cartId

I have 4 stores in my project.

enter image description here

Order edit works fine for 1 store but for another store it gives error
and in DB for 1 store it inserts 2 rows, for another 4 rows.

I am not getting anything.
Working on multi-site setup.

Best Answer

The problem is that the current store has always the default store ID in the admin panel (on the fronted everything is OK).

As result I catch the No such entity with cartId = xxx ... exception, because Magento tries to retrieve quote with this ID from the default store, which does not exist.

$store_old = $this->_storeManager->getStore();

$store = $this->_storeManager->getStore(Pass YOUR STORE ID);

$this->_storeManager->setCurrentStore($store); // Add this to avoid cart issue
Related Topic