7

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.

7
  • If anybody have questions about this issue plz ask. Dec 7, 2016 at 12:41
  • i have a question nitesh...how i solve this issue please give me a solution.....
    – Doss
    Apr 11, 2018 at 11:03
  • @Doss In my case, there was one extension we were using and because of that extension we were facing this issue, then after disable that extension, issue was fixed. After that, we found out that conflict (unable to remember all things) and finally solved this issue. Apr 11, 2018 at 12:19
  • @Doss Can you tell more about your issue? Apr 11, 2018 at 12:20
  • When I Give invoice for my order in admin side...Sales->Settings->orders->Invoice..No such entity with cartId = 458 error message is shown..What is the problem for that.please give me a solution @nitesh
    – Doss
    Apr 11, 2018 at 12:54

2 Answers 2

3

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
0

Be sure to check your theme directories for any mis-use of Magento_Customer/js/customer-data I have found on multiple occasions when debugging that many devs opt to manipulate customer data to achieve things. Here was one I found recently in the placeOrder: function () { method of a third-party payment gateway integration that had been internally manipulated within the theme:

var clearData = {
  'selectedShippingAddress': null,
  'shippingAddressFromData': null,
  'newCustomerShippingAddress': null,
  'selectedShippingRate': null,
  'selectedPaymentMethod': null,
  'selectedBillingAddress': null,
  'billingAddressFromData': null,
  'newCustomerBillingAddress': null
};
customerData.set('checkout-data', clearData);

So search app/design/frontend for Magento_Customer/js/customer-data and see what naughties pop-up!

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.