Read magento 2 no such entity with customerid for more information.

If you receive the error message “No such entity.”, “No such entity with” or “No such entity with customerId” in Magento 2, the issue usually occurred when you try to load not existing object via Magento 2 Repository Class.
magento 2 no such entity with customerid

Add a search bar to Magento

Sorry to say this, but as usual, after upgrading Magento versions something is wrong at the end. I did have no exceptions and no errors before. Now upgrading to 2.3.2 I get exceptions like: [2019-06-25 21:46:34] main.CRITICAL: Keine Eintrag mit customerId = 1 {“exception”:”[object] (Magento\\Framework\\Exception\\NoSuchEntityException(code: 0): Keine Eintrag mit customerId = 1 at /var/www/vhosts/hopfenmuseum-tettnang.de/magento.hopfenexpress.de/vendor/magento/framework/Exception/NoSuchEntityException.php:50)”} []

To debug this issue, please open the file

vendor/magento/framework/Exception/NoSuchEntityException.php

and at the beginning of the __construct method temporary add debug backtrace code:

foreach (debug_backtrace() as $_stack) {
    echo ($_stack["file"] ? $_stack["file"] : '') . ':' .
        ($_stack["line"] ? $_stack["line"] : '') . ' - ' .
        ($_stack["function"] ? $_stack["function"] : '');
}
exit();

example:

public function __construct(Phrase $phrase = null, \Exception $cause = null, $code = 0)
 {

    foreach (debug_backtrace() as $_stack) {
        echo ($_stack["file"] ? $_stack["file"] : '') . ':' .
            ($_stack["line"] ? $_stack["line"] : '') . ' - ' .
            ($_stack["function"] ? $_stack["function"] : '');
     }
    exit();


    if ($phrase === null) {
        $phrase = new Phrase('No such entity.');
    }
    parent::__construct($phrase, $cause, $code);
 }

save the file and refresh the page.

You will see the debug backtrace that will allow you to define the issue source and you will get an idea how to fix it.

Usually third party Magento 2 extensions lead up to this problem, so you can override their code and add “try-catch” exception.

Don’t forget to revert changes in NoSuchEntityException.php file after you’re finished.

Searches related to magento 2 no such entity with customerid

You may also like