Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get default store id of website in Magento

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?

like image 504
user773440 Avatar asked Jun 28 '12 11:06

user773440


People also ask

How can I get store ID in Magento 2?

You can get store ID by calling the block function in your phtml file. echo $block->getStoreId(); Using Object Manager.

Where is store ID in Magento?

You need to go to System > Manage Stores and click on the store name in the right-hand column. Then check the URL for the store_id element - this is your store ID on Magento.

How do you find a website ID?

Go to Administration (click on the gear icon in the top right of the screen). Click on the Measurables(or Websites) > Manage page. You will find a list of all websites on this page. The website ID is on the left of the table listing all websites directly below the website name.


2 Answers

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();
like image 99
Jürgen Thelen Avatar answered Oct 01 '22 12:10

Jürgen Thelen


you can get default store id like following:

Mage_Core_Model_App::ADMIN_STORE_ID
like image 24
Hassan Ali Shahzad Avatar answered Oct 01 '22 13:10

Hassan Ali Shahzad