Sometimes when we are in the programming of our magento modules, we need to access data from a store in question, usually the store that the user has active, it can be easily obtained by instantiating our Mage class and using one of its methods
Get active store data :
With this value in memory can now access the specific values we need, for example if you want to know the name of the store could get this:
$store = Mage::app()->getStore(); $storeName = $store->getName();
And another possibility :
$store = Mage::app()->getStore(); $storeName = $store->getData('name');
When we shop name in this example, we refer to the field 'name' from core_store table, which stores the name of the view of the store, not to confuse with the public name of the store that would be obtained in this way .
$storePublicName = Mage::app()->getStore()->getFrontendName();
Now we learned to access the active store attributes, but as we would if we want to access data from any of our stores?
Get store data by primary key (store_id)
For this would access directly to the 'core/store ' model and with the usage of the method getModel () ->load ($storeId) would get the same data that we saw in the previous examples :
$store = Mage::getModel('core/store')->load($storeId); $storeName = store->getName(); $storePublicName = $store->getFrontendName();