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.
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityI 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.
Simplest way I can think is:
Mage::getModel('core/store')->load($storeId);
So use :
$store_ids= array(1,2,3);
foreach($store_ids as $storeId){
$store = Mage::getModel('core/store')->load($storeId);
$name = $store->getName();
}
That's what else you can have from object $store:
[code] =>
[website_id] =>
[group_id] =>
[name] =>
[sort_order] =>
[is_active] =>
Use below:
$store_ids= array(1,2,3); $stores=Mage::getModel('core/store')->getCollection()
->addFieldToFilter('store_id',array('in'=>$store_ids))->addFieldToSelect('name');foreach( $stores as $eachStore){ echo $eachStore->getName(); }
As you want to only store name of multiple stores
that why i am suggest to use store collection and filter them by store_id
instead of use store model(Mage::getModel('core/store')) and load them one by one.
It is better for coding.
Mage::getModel('core/store')->getCollection()