user4837126
user4837126

Reputation:

How to get Store Name by using Multiple Store Id in Magento?

I want to get store name by using multiple store ids in magento. like:

<?php $store_ids= array(1,2,3);

Now how to get store names of these store ids.

Upvotes: 2

Views: 15639

Answers (3)

user4837126
user4837126

Reputation:

I got the answer:

We can get storename through multiple store ids like this:

$store_ids= array(1,2,3);
foreach($store_ids as $storeId){
    $store = Mage::getModel('core/store')->load($storeId);
    $name = $store->getName();
}

Upvotes: 2

Subhranil Jana
Subhranil Jana

Reputation: 119

// Gets the current store's details  
 $store = Mage::app()->getStore();

// Gets the current store's id
 $storeId = Mage::app()->getStore()->getStoreId();

// Gets the current store's code $storeCode =
 Mage::app()->getStore()->getCode();

// Gets the current website's id
 $websiteId = Mage::app()->getStore()->getWebsiteId();

// Gets the current store's group id
 $storeGroupId = Mage::app()->getStore()->getGroupId();

// Gets the current store's name
 $storeName = Mage::app()->getStore()->getName();

// Gets the current store's sort order
 $storeSortOrder = Mage::app()->getStore()->getSortOrder();

// Gets the current store's status
 $storeIsActive = Mage::app()->getStore()->getIsActive();

// Gets the current store's locale
 $storeLocaleCode = Mage::app()->getStore()->getLocaleCode();

// Gets the current store's home url
 $storeHomeUrl = Mage::app()->getStore()->getHomeUrl();

Upvotes: 3

Subhranil Jana
Subhranil Jana

Reputation: 119

echo "Website ID: " . Mage::app()->getWebsite()->getId() . "<br/>";  
echo "Website Name: " . Mage::app()->getWebsite()->getName() . "<br/>"; 
echo "Store ID: " . Mage::app()->getStore()->getId() . "<br/>";  
echo "Store Name: ".Mage::app()->getStore()->getName(). "<br/>"; 
echo "Store code: ". Mage::app()->getStore()->getCode()."<br/>";

The below code snippet will print all the store IDs and store names in Magento.

foreach (Mage::app()->getWebsites() as $website) {
    foreach ($website->getGroups() as $group) {
        $stores = $group->getStores();
        foreach ($stores as $store) {
            echo $store->getId() ." ".$store->getName()."<br/>";
        }
    } }

Upvotes: 2

Related Questions