How to get the ID of a store by name?
-
28-09-2020 - |
Question
Let´s say I have a store named "Megastore". How can I get the id of that specific store?
Can I do it by using some kind of filter?
Mage::getModel('core/store')->addFieldToFilter('name', 'Megastore');
Solution 2
Actually found the solution here: How to get the store id from the code
Mage::app()->getStore('Megastore')->getId()
OTHER TIPS
What do you need the ID for? Are you writing code for a specific store? If so you can do
<?php if (Mage::app()->getStore()->getCode() == 'default'){ ?>
Default being the store name.
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange