How do I get the default store ID of a website in Magento?
24,617
Solution 1
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();
Solution 2
you can get default store id like following:
Mage_Core_Model_App::ADMIN_STORE_ID
Author by
user773440
Updated on December 22, 2021Comments
-
user773440 over 2 years
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?
-
Tahir Yasin over 10 yearsThis doesn't work in Magento admin scope but works on front-end.