16

I want to get the default store ID of currently active website. I tried Mage::app()->getStoreId(), but that gets the current store, not the default store ID of the current website.

How can I get it?

TylerH
  • 20,799
  • 66
  • 75
  • 101
user773440
  • 868
  • 1
  • 12
  • 23

2 Answers2

19

Assuming you're talking about the default store id defined per store group, then e.g. like this:

$iDefaultStoreId = Mage::app()
    ->getWebsite()
    ->getDefaultGroup()
    ->getDefaultStoreId();

The original question was on how to retrieve the default store ID of currently active website, so the answer is correct. However in order to get the default frontend store ID from within the admin panel you need to pass the parameter true to the method getWebsite() :

$iDefaultStoreId = Mage::app()
    ->getWebsite(true)
    ->getDefaultGroup()
    ->getDefaultStoreId();
Alexey Varlamov
  • 131
  • 3
  • 8
Jürgen Thelen
  • 12,745
  • 7
  • 52
  • 71
2

you can get default store id like following:

Mage_Core_Model_App::ADMIN_STORE_ID
Hassan Ali Shahzad
  • 2,439
  • 29
  • 32