3

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
14

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;
| improve this answer | |
  • 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
18

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';
| improve this answer | |
3

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

| improve this answer | |
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 = [];
| improve this answer | |
0

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

| improve this answer | |
0

in my case , magento 1.9 upgrade to magento 2.3

I re-added the store item.

I re-added the store item.

| improve this answer | |
0

If the above doesn't fix the issue and it relates to CMS pages, you can look at the database table cms_page_store and see what the store id that is missing by using the following query:

select * from cms_page_store where store_id > put your current max store id here

You can fix this by assigning a current store id to those pages:

update cms_page_store set store_id = 2 where store_id = store id that doesn't exist
| improve this answer | |
0

This generally happens whenever config.php and the database get out of sync. For example, whenever I import a database back to my local development environment.

Here were the steps I used to troubleshoot and fix this.

  1. Make the error messages more helpful:

Change vendor/magento/module-store/Model/StoreRepository.php to this (on your local, temporarily)

// Around line 74
        if ($store->getId() === null) {
        
// Add this to see a backtrace
            // debug_print_backtrace();            

// Add this to see the store code causing the issue: (code:{$code})
            throw new NoSuchEntityException(
                __("The store (code:{$code}) that was requested wasn't found. Verify the store and try again.")
            );
        }
        
// .......
// Around line 114, same kind of thing...

        if ($store->getId() === null) {

            // debug_print_backtrace();

            throw new NoSuchEntityException(
                __("The store ID ({$id}) that was requested wasn't found. Verify the store and try again.")
            );
        }        

Run php bin/magento s:up and make a note of the store id and/or store codes that are causing the issues. If you have added the backtrace, that will spool variables forever and you might need to do something like this instead: php bin/magento s:up > output.txt (wait 3 minutes, press ctrl-d to kill it) less output.txt

  1. Go through app/etc/config.php and make sure all the stores line up with whatever is in the store table in the database. Note the store id from step 1, that will give you clues where to look. If there are differences, change config.php and not the database.

  2. Run this against the database:

## Change scope_id value (99) to whatever store_id you got in step #1
DELETE FROM `core_config_data` WHERE scope_id = 99

## Change like value ('%xx_en%') to whatever store code you got in step #1
DELETE from flag where flag_data like '%xx_en%'
  1. Run php bin/magento s:up again, hopefully there are no errors this time. Otherwise you may have to repeat some steps.
| improve this answer | |
-3

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.

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

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