6

I'm using 2.3

But I don't know why when I place an Order I am getting No such entity with orderId=

How can I fix it?

look like this issue

enter image description here

update:

I check in chrome when i place an Order will showing

POST http://XXXX/rest/en/V1/carts/mine/payment-information 400 (Bad Request)

<response>
<message>
The consumer isn't authorized to access %resources.
</message>
<parameters>
<resources>self</resources>
</parameters>
<trace>
#0 public_html/vendor/magento/module-webapi/Controller/Rest/RequestValidator.php(68): Magento\Webapi\Controller\Rest\RequestValidator->checkPermissions() #1 public_html/vendor/magento/module-webapi/Controller/Rest/InputParamsResolver.php(80): Magento\Webapi\Controller\Rest\RequestValidator->validate() #2 public_html/vendor/magento/module-webapi/Controller/Rest/SynchronousRequestProcessor.php(85): Magento\Webapi\Controller\Rest\InputParamsResolver->resolve() #3 public_html/vendor/magento/module-webapi/Controller/Rest.php(188): Magento\Webapi\Controller\Rest\SynchronousRequestProcessor->process(Object(Magento\Framework\Webapi\Rest\Request\Proxy)) #4 public_html/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Webapi\Controller\Rest->dispatch(Object(Magento\Framework\App\Request\Http)) #5 public_html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Webapi\Controller\Rest\Interceptor->___callParent('dispatch', Array) #6 public_html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Webapi\Controller\Rest\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http)) #7 public_html/generated/code/Magento/Webapi/Controller/Rest/Interceptor.php(26): Magento\Webapi\Controller\Rest\Interceptor->___callPlugins('dispatch', Array, Array) #8 public_html/vendor/magento/framework/App/Http.php(135): Magento\Webapi\Controller\Rest\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http)) #9 public_html/generated/code/Magento/Framework/App/Http/Interceptor.php(24): Magento\Framework\App\Http->launch() #10 public_html/vendor/magento/framework/App/Bootstrap.php(258): Magento\Framework\App\Http\Interceptor->launch() #11 public_html/index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http\Interceptor)) #12 {main}
</trace>
</response>
11
  • which id do you get on error?
    – fmsthird
    Commented Jan 26, 2019 at 22:19
  • Check my updated. @magefms
    – niceonelee
    Commented Jan 27, 2019 at 7:26
  • you can debugging more using my answer Commented Jan 27, 2019 at 7:33
  • i'm trying, please wait @RakeshDonga
    – niceonelee
    Commented Jan 27, 2019 at 7:45
  • please check my new updated @magefms
    – niceonelee
    Commented Jan 27, 2019 at 8:14

3 Answers 3

5

I had the same error before.But on Magento 2.2.8 For my case the problem was only if you did a checkout as logged in customer and not as quest. The errors was coming from that file:

vendor/magento/module-sales/Model/ResourceModel/Order/Plugin/Authorization.php

function: after load

which is checking if the order is allowed for current customer. For my occasion again I was getting that error because of a custom Module which was doing something with the invoice before the moment it should. So I would start debugging my code to see when this function is called and which action is calling it.

I hope it helps someone.

1
  • How did you fixed this issue @vbak ? As I am facing the exact issue now
    – aravind
    Commented Dec 15, 2020 at 7:39
4

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

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.

5
  • Hi, but this is new 2.3, why i need change the vendor file? thank you
    – niceonelee
    Commented Jan 27, 2019 at 7:42
  • 1
    just for debug after revert it Commented Jan 27, 2019 at 7:45
  • i chagned with you same and then text in checkout , it nothing showing about what. not working. please help,thank you!
    – niceonelee
    Commented Jan 27, 2019 at 7:55
  • @RakeshDonga this solution returns an error in NoSuchEntityException that 'index' is not defines (see magento.stackexchange.com/questions/276051/…)
    – SylwekFr
    Commented Oct 2, 2019 at 10:32
  • Superb answer bro. Thanks. I have found which extension caused this. Thank you very much.
    – Goutam
    Commented Feb 20, 2020 at 9:18
1

Check url_rewrite table in your database, perform this SQL query

select * from url_rewrite where target_path like '%/category/orderId(in your error)%'
delete from url_rewrite where target_path like '%/category/orderId(in your error)%';

select * from url_rewrite where entity_type='category' and entity_id=orderId(in your error);
delete from url_rewrite where entity_type='category' and entity_id=orderId(in your error);
3
  • Check my updated
    – niceonelee
    Commented Jan 27, 2019 at 7:28
  • found this while searching on the internet, it might be helpful to you. SET FOREIGN_KEY_CHECKS=0; 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'; SET FOREIGN_KEY_CHECKS=1;`
    – fmsthird
    Commented Jan 27, 2019 at 7:42
  • May i know what is this? this is about customer_group?
    – niceonelee
    Commented Jan 27, 2019 at 8:08

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.