cancel
Showing results for 
Search instead for 
Did you mean: 

No such entity with id = 3

SOLVED

No such entity with id = 3

I am trying to update a category and got an error.


I did these steps:

  1.  I removed all my categories with below query

    SET FOREIGN_KEY_CHECKS = 0;
    DELETE FROM catalog_category_entity WHERE entity_id > 2;
    DELETE FROM url_rewrite WHERE entity_type = 'category';
    SET FOREIGN_KEY_CHECKS = 1;

  2. I added some category by code. It is showing fine in the backend and frontend. I have no issue with this.
  3. After that I added some product and assign a category in csv but category is not showing in the added products and when I try to update this with assign category
    it is showing me an error "No such entity with id = 3"
  4. Also when I try to update any category it is showing same error "No such entity with id = 3"

Please resolve, If you know anything about this.

I run the reindex command and cache flush command but it's not working.

5 REPLIES

Re: No such entity with id = 3

Hi @Neeraj02381

 

Looks like you have some issue related to store 

 

Run below script and then check 

 

 

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;


After running this - run indexing command again like - php bin/magento indexer:reindex

php bin/magento cache:clean

php bin/magento cache:flush

 

Then check it might works for you !

if issue solved,Click Kudos & Accept as Solution

Re: No such entity with id = 3

I already try this but didn't get any luck

Re: No such entity with id = 3

Hi @Neeraj02381

 

ok i understand ! can you please check error log in var/log directory and post over here ? so its help us to troubleshoot the issue

if issue solved,Click Kudos & Accept as Solution

Re: No such entity with id = 3

@ManthanDave:

Here is my exception.log

[2018-06-19 11:08:52] main.CRITICAL: No such entity with id = 3 {"exception":"[object] (Magento\\Framework\\Exception\\NoSuchEntityException(code: 0): No such entity with id = 3 at D:\\xampp\\htdocs\\meg\\vendor\\magento\\framework\\Exception\\NoSuchEntityException.php:49)"} []

 

 

 

Re: No such entity with id = 3

@ManthanDave

I commented a code in vendor\magento\module-catalog\Model\CategoryRepository.php file line no. 141

if (!$category->getId()) {
        throw NoSuchEntityException::singleField('id', $categoryId);
}

Now it is working fine.

Please let me know it is the correct way or not or I need to do something else.