I am trying to update a category and got an error.
I did these steps:
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;
Please resolve, If you know anything about this.
I run the reindex command and cache flush command but it's not working.
Solved! Go to Solution.
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.
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 !
I already try this but didn't get any luck
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
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)"} []
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.
Root cause of this issue is data in url_rewrite table related to removed category id 3.
select * from url_rewrite where target_path like '%/category/3%'
delete from url_rewrite where target_path like '%/category/3%';
select * from url_rewrite where entity_type='category' and entity_id=3;
delete from url_rewrite where entity_type='category' and entity_id=3;
I fixed similar issue by above workaround.
Oops!
select * from url_rewrite where target_path like '%/category/3';
delete from url_rewrite where target_path like '%/category/3';
Delete only rows with target path end with /category/3.
This is not the right way. We cannot edit the core file to hide issues.
Assuming your site is in `Developer Mode`, you can change it to `Production Mode` and clear/flush cache and then switch back to `Developer Mode`.
I had this issue in the front end, as i recently moved the database from one server to another. I have managed to solve by this way.
Tried your solution and received:
MySQL returned an empty result set (i.e. zero rows)
and
0 rows affected.
What else can it be?