Uncaught exception: Mage_Core_Model_Store_Exception

11,221

Solution 1

I added Mage::app('main'); after require_once 'app/Mage.php';

require_once 'app/Mage.php'; 
Mage::app('main');

where 'main' is my store's code. I have only one store in Magento.

I found this solution in another file I'm using which contains require_once 'app/Mage.php' but doesn't give an error. I don't know why it worked, but it did.

Solution 2

Looking in the stack trace the error is occurring is here:

app/code/core/Mage/Core/Model/App.php(491): Mage_Core_Model_App->getStore();

Can you give us more background on this? Did your site ever work? Have you recently changed the store settings eg deleted a store?

If you use a different browser or a different computer to access your website does that work?

Cookies are used to tell Magento which store you want to visit so try removing all your cookies.

What else? Maybe an XML file is missing or erroneous and the store setting can't be found by Magento configuration.

Try some of these things then please give more background: eg Is this a fresh Magento install? Can you access the Magento admin pages? Has this ever worked? Are you in production? Deve;opmet? Running locally on XAMP? Recently changed your store configuration? Recently changed or moved XML files? Switched to a new theme?

Solution 3

_initCurrentStore('default', 'store')

As you can see from code above, you're trying to initialize 'default' store, which doesn't exist for you. That's because you've probably changed your default store name, so Magento cannot find it on load.

Solution for you is to use code fix that you mentioned, and just try to set your default store/website. That will update core_config_data with proper value for default store/website. After that, clean cache and remove that line that you've added, and it should work.

Share:
11,221
zekia
Author by

zekia

Updated on November 26, 2022

Comments

  • zekia
    zekia over 1 year
    Fatal error:  Uncaught exception 'Mage_Core_Model_Store_Exception' in /home/mywebsite/public_html/app/code/core/Mage/Core/Model/App.php:1357
    
            Stack trace:
                #0 /home/mywebsite/public_html/app/code/core/Mage/Core/Model/App.php(842): Mage_Core_Model_App->throwStoreException()
                #1 /home/mywebsite/public_html/app/code/core/Mage/Core/Model/App.php(491): Mage_Core_Model_App->getStore()
                #2 /home/mywebsite/public_html/app/code/core/Mage/Core/Model/App.php(274): Mage_Core_Model_App->_initCurrentStore('default', 'store')
                #3 /home/mywebsite/public_html/app/Mage.php(615): Mage_Core_Model_App->init('default', 'store', Array)
                #4 /home/mywebsite/public_html/pricerule.php(6): Mage::app('default')
                #5 {main}
    
    thrown in <b>/home/mywebsite/public_html/app/code/core/Mage/Core/Model/App.php</b> on line <b>1357</b>
    

    This error occurs on this line:

    require_once 'app/Mage.php';
    
    • PDO is enabled
    • I have copied php.ini file in app and downloader directories
    • app, downloader, media and var directories have been set to 777 permissions

    These are all suggested solutions for this particular error, but none of them worked for me. Any other suggestions please??


    EDIT -- SOLUTION ---------------------

    I added the following line after require_once 'app/Mage.php';

    require_once 'app/Mage.php';
    Mage::app('main');
    

    where 'main' is my store's code. I have only one store in Magento.

    I found this solution in another file I'm using which contains require_once 'app/Mage.php' but doesn't give an error. I don't know why it worked, but it did.

  • qwerty
    qwerty about 3 years
    In which file need to add the above line?