2

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]
  • Remove var folder and check it again. – Suresh Chikani Jan 24 '17 at 10:33
  • share the error which command promt show to you. – Dhiren Vasoya Jan 25 '17 at 3:04
  • @DhirenVasoya : Added the error in question – Zammuuz Jan 25 '17 at 4:22
12

You need to run following query in your database, and then try to open 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;
  • No this didn't solved the issue. :( – Zammuuz Jan 25 '17 at 2:17
  • This is the only thing that worked for me! – Wildcard27 Apr 29 '17 at 2:18
  • Thank you very much Dhiren Vasoya, it worked for me to. Tested on Magento 2.2 – Andhi Irawan Jan 24 '18 at 13:09
  • @Dhiren Vasoya what this command actually do ? – ephemeral Feb 8 '18 at 12:09
  • Some times dua to some reason, default store_id may be changes, So above command set it default again, and magento working fine. – Dhiren Vasoya Feb 8 '18 at 14:09
15

I just recently came across this same situation after migrating from Magento 1.6.1.0 to 2.1.4 and hope my answer can be of assistance. The problem came from deleting multiple stores 96 of them to be exact. I tried all the other answers here but was still getting the same error.

The fix for me was removing the old store data from inside of the "core_config_data". The problem is that when the Magento is loading the run time configuration data it is finding the old stores and trying to resolve them. Before cleaning the data from the database I HIGHLY recommend you run the SELECT query below to make sure you delete the correct stores.

SELECT * FROM core_config_data WHERE scope = 'stores';

WARNING: MAKE SURE TO BACKUP YOUR DATABASE BEFORE RUNNING THIS!

DELETE FROM core_config_data WHERE scope_id != 1 AND scope = 'stores';
2

In this case, I have to restore that tables store, store_group, store_website. As it was before the migration Magento 2

enter image description here

0

The error occurred for me during a reindex of Catalog Search while using the Elasticsearch engine. Magento 2.0.0 Commerce (and possibly other versions) have a bug resolved by the following patch.

diff --git a/vendor/magento/module-elasticsearch/Model/Adapter/BatchDataMapper/PriceFieldsProvider.php b/vendor/magento/module-elasticsearch/Model/Adapter/BatchDataMapper/PriceFieldsProvider.php
index aa89657..f5e8a23 100644
--- a/vendor/magento/module-elasticsearch/Model/Adapter/BatchDataMapper/PriceFieldsProvider.php
+++ b/vendor/magento/module-elasticsearch/Model/Adapter/BatchDataMapper/PriceFieldsProvider.php
@@ -50,9 +50,8 @@ class PriceFieldsProvider implements AdditionalFieldsProviderInterface
      */
     public function getFields(array $productIds, $storeId)
     {
-        $websiteId = $this->storeManager->getStore($storeId)->getWebsiteId();
         $priceData = $this->dataProvider->getSearchableAttribute('price')
-            ? $this->resourceIndex->getPriceIndexData($productIds, $websiteId)
+            ? $this->resourceIndex->getPriceIndexData($productIds, $storeId)
             : [];

         $fields = [];
0

Confirm your store id and delete all the records of store which doesn't exist 'cms_page_store' & 'cms_block_store'...

0

in my case , magento 1.9 upgrade to magento 2.3

I re-added the store item.

I re-added the store item.

-2

It's a bug in Magento 2 already fixed in develop.

All query results to tables store, store_group, store_websites are being cached. The problem occurs because cache isn't cleaned properly after store, store group or website is added/deleted.

To get a fix see changes in app/code/Magento/Store/etc/di.xml and app/code/Magento/Store/Model/StoreManager.php.

It must resolve the issue.

  • What does "To get a fix see changes in..." mean? – Adam Lavery Dec 15 '17 at 9:26

protected by Community Sep 28 '17 at 12:49

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.