Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to fetch store name and other store details from system configuration in magento

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 576
    Comment on it

    In magento sometimes we need to get the current store details from system configuration for some reference,


    Then lets see how can we do it :

     

    1. To get all the stores  from magento  

    for the same we can use

     

    Mage::app()->getStores();

     

    The above code will get all the stores from the magento in the form of array of Mage_Core_Model_Store model.

     

    2. To get the current store code

    for the same we can do it as :

     

    Mage::app()->getStore()->getCode();

     

    The above code will fetch the current store Code. It wont returns the numeric code instead it will return character code example 'en' for 'English'.

     

    3. If we need to check if the store is enabled

    for the same we can use

     

    Mage::app()->getStore()->getIsActive();

    The above code will get the value of IsActive attribute to determine if the store is enabled.

     

    4. If we need to get the current store ID we can get by :

     

    Mage::app()->getStore()->getStoreId();

     

    In the above code  we are fetching the StoreId attribute value which contains the store id.

     

    5. If we need to get the current store model:

    To fetch the store model :

     

    Mage::app()->getStore();

     

    the above code returns the model of the store as Mage_Core_Model_Store.

     

    6. If wee ned to get the frontend name of the store view

    for the same do it as :

     

    Mage::app()->getStore()->getFrontendName();

     

    the abve code fetches the FrontendName attribute value and returns the frontend name of the store view.

     

    7. To get the website ID for current store do it as:

     

    Mage::app()->getStore()->getWebsiteId();

     

    in the above code it fetches the Website Id from the attribute WebsiteId.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: