Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8605351
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:48:34+00:00 2026-06-12T02:48:34+00:00

I am trying to find out the default store code from within Magento’s backend.

  • 0

I am trying to find out the default store code from within Magento’s backend. While this sounds rather simple, I just couldn’t find any solution.

The snippets I found are either

Mage::app()->getStore()->getCode()

(although this doesn’t correspond to the default but the current store) or

Mage::app()->getStore(Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID)->getCode();

But from within the backend these will only return "admin" (since the backend is treated as some kind of special store with store ID 0 – which is the value of DEFAULT_STORE_ID). Could anyone please point me to a way to get the actual default store code from anywhere? (That store code that is set by Magento if both "Add Store Code to URLs" and "Auto-redirect to Base URL" options are activated)

Just a little background why I need this: I need to generate a URL within the Magento configuration that still works if "Add Store Code to URLs" is activated. I can set any store code, so if I’m within the configuration scope of one of them, I can just use that one. But since it also has to work if the configuration scope is set to default or website, I want to use the default store code in that case.

I found a solution with:

$websites = Mage::app()->getWebsites();
$code = $websites[1]->getDefaultStore()->getCode();

However, this leaves me with some follow-up questions.

Why does Mage::app()->getWebsite() return a special website object that only includes the special admin store, while Mage::app()->getWebsites() will return an array that only includes the usual frontend website, but not the object returned by getWebsite()?

Why does the frontend website object occupy index 1 in the array, while index 0 is unused? I would really like to know the reason for having to use a magic number there (if I have to).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T02:48:36+00:00Added an answer on June 12, 2026 at 2:48 am

    There is no such thing as a default store in Magento. The only special store is the admin one; all other stores have the same rights in Magento.

    […] while Mage::app()->getWebsites() will return an array that only
    includes the usual frontend website, but not the object returned by
    getWebsite()?

    You should look at Mage_Core_Model_App::getWebsites()‘s source code:

    public function getWebsites($withDefault = false, $codeKey = false)
    {
        $websites = array();
        if (is_array($this->_websites)) {
            foreach ($this->_websites as $website) {
                if (!$withDefault && $website->getId() == 0) {
                    continue;
                }
                //...
            }
        }
    
        return $websites;
    }
    

    If you call $websites = Mage::app()->getWebsites(true);, you will get an array of websites, with the admin one at index 0.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to find out which edges from a graph are bidirectional. Each
i feel my beard growing while trying to find out the Problem here. Basic
I am trying to find out what is causing this error, I have listed
Trying to find out if it's possible to use SQLAlchemy on Heroku. Thanks.
I trying to find out the visibility of the Excel and do some activities
I am trying to find out how to write an SQL statement that will
i m trying to find out how to convert timestamp date and time (
I am trying to find out a way to set a time tag to
I am trying to find out if an instance of an application (not vb.net)
I'm trying to find out how to change the icon of a JStree node

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.