如何在 Magento 中使用多个商店 ID 获取商店名称?

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

我想在 magento 中使用多个商店 ID 来获取商店名称。 喜欢:

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

现在如何获取这些商店 ID 的商店名称。

我得到了答案:

我们可以像这样通过多个store id获取storename:

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

下面的代码片段将打印 Magento 中的所有商店 ID 和商店名称。

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