Magento 2 Store Not Found – How to Resolve Requested Store Issues

exceptionmagento-2.1.3storeswebsites

I had two websites with different store and storeviews. I just deleted one website which is not the default one. After deleting it the admin panel page and also the front page shows this error

exception 'Magento\Framework\Exception\NoSuchEntityException' with message 'Requested store is not found' in C:\wamp\www\magento\vendor\magento\module-store\Model\StoreRepository.php:111 Stack trace: #0 

C:\wamp\www\magento\vendor\magento\module-store\Model\StoreManager.php(164): Magento\Store\Model\StoreRepository->getById('2') #1 C:\wamp\www\magento\var\generation\Magento\Store\Model\StoreManagerInterface\Proxy.php(119): Magento\Store\Model\StoreManager->getStore('2') #2 C:\wamp\www\magento\vendor\magento\module-store\Model\Resolver\Store.php(29): Magento\Store\Model\StoreManagerInterface\Proxy->getStore('2') #3 C:\wamp\www\magento\vendor\magento\framework\App\Config\ScopeCodeResolver.php(49): Magento\Store\Model\Resolver\Store->getScope('2') #4 C:\wamp\www\magento\vendor\magento\module-config\App\Config\Source\RuntimeConfigSource.php(82): Magento\Framework\App\Config\ScopeCodeResolver->resolve('stores', '2') #5 C:\wamp\www\magento\vendor\magento\module-config\App\Config\Source\RuntimeConfigSource.php(58): Magento\Config\App\Config\Source\RuntimeConfigSource->loadConfig() #6 C:\wamp\www\magento\vendor\magento\framework\App\Config\ConfigSourceAggregated.php(40): Magento\Config\App\Config\Source\RuntimeConfigSource->get('') #7 C:\wamp\www\magento\var\generation\Magento\Framework\App\Config\ConfigSourceAggregated\Proxy.php(95): Magento\Framework\App\Config\ConfigSourceAggregated->get('') #8 C:\wamp\www\magento\vendor\magento\module-config\App\Config\Type\System.php(98): Magento\Framework\App\Config\ConfigSourceAggregated\Proxy->get() #9 C:\wamp\www\magento\vendor\magento\framework\App\Config.php(139): Magento\Config\App\Config\Type\System->get('default/web/sec...') #10 C:\wamp\www\magento\vendor\magento\framework\App\Config.php(90): Magento\Framework\App\Config->get('system', 'default/web/sec...') #11 C:\wamp\www\magento\vendor\magento\framework\App\Config.php(103): Magento\Framework\App\Config->getValue('web/secure/use_...', 'default', NULL) #12 C:\wamp\www\magento\vendor\magento\module-store\Model\HeaderProvider\Hsts.php(48): Magento\Framework\App\Config->isSetFlag('web/secure/use_...') #13 C:\wamp\www\magento\vendor\magento\framework\App\Response\HeaderManager.php(41): Magento\Store\Model\HeaderProvider\Hsts->canApply() #14 C:\wamp\www\magento\vendor\magento\framework\Interception\Interceptor.php(123): Magento\Framework\App\Response\HeaderManager->beforeSendResponse(Object(Magento\Framework\App\Response\Http\Interceptor)) #15 C:\wamp\www\magento\var\generation\Magento\Framework\App\Response\Http\Interceptor.php(117): Magento\Framework\App\Response\Http\Interceptor->___callPlugins('sendResponse', Array, Array) #16 C:\wamp\www\magento\vendor\magento\framework\App\Http.php(185): Magento\Framework\App\Response\Http\Interceptor->sendResponse() #17 C:\wamp\www\magento\vendor\magento\framework\App\Http.php(156): Magento\Framework\App\Http->handleDeveloperMode(Object(Magento\Framework\App\Bootstrap), Object(Magento\Framework\Exception\NoSuchEntityException)) #18 C:\wamp\www\magento\vendor\magento\framework\App\Bootstrap.php(263): Magento\Framework\App\Http->catchException(Object(Magento\Framework\App\Bootstrap), Object(Magento\Framework\Exception\NoSuchEntityException)) #19 C:\wamp\www\magento\index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http)) #20 {main}

What should I do now? I tried

php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy
php bin/magento indexer:reindex

from command prompt. But it shows the same error in command prompt also. The cmd error is :

C:\wamp\bin\php\php5.6.30>php C:\wamp\www\magento\bin\magento indexer:reindex
Xdebug requires Zend Engine API version 220121212.
The Zend Engine API version 220131226 which is installed, is newer.
Contact Derick Rethans at http://xdebug.org/docs/faq#api for a later version of Xdebug.




  [Magento\Framework\Exception\NoSuchEntityException]
  Requested store is not found



indexer:reindex [index1] ... [indexN]

Best Answer

You need to run the following query in your database, and then try to open the website.

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;
Related Topic