Search code examples
phpmagento

How to get store information in Magento?


In Magento, how can I get active store information, like store name, line number, etc?


Solution

  • To get information about the current store from anywhere in Magento, use:

    <?php
    $store = Mage::app()->getStore();
    

    This will give you a Mage_Core_Model_Store object, which has some of the information you need:

    <?php
    $name = $store->getName();
    

    As for your other question about line number, I'm not sure what you mean. If you mean that you want to know what line number in the code you are on (for error handling, for instance), try:

    <?php
    $line      = __LINE__;
    $file      = __FILE__;
    $class     = __CLASS__;
    $method    = __METHOD__;
    $namespace = __NAMESPACE__;