Tuesday, 4 February 2014

Magento : Get Store Id/Website Id



After hours of huffing and puffing i was able to figure out a way to get the store information programmatically :)

Get current store:

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

Get current store Id:

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


Get current website Id:


$storeId = Mage::app()->getStore()->getId();
Mage::getModel('core/store')->load( $storeId )->getWebsiteId();

Get store info by store code:

            $storeCode = "your_store_code";

Mage::getModel( "core/store" )->load( $storeCode );

Get website info by website code:

            $websiteCode = "your_website_code";

Mage::getModel( "core/website" )->load( $websiteCode );

Get all stores:

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

Let me know in the comments if this has helped you........... Enjoy........Happy coding :)....

7 comments:

  1. Nice post.I am looking forward for new ones, keep up the great work.

    ReplyDelete
  2. Thanks for your ideas. You can also find the details on Affity Solutions, at the
    Magento Website Australia. The main object of the Affity Solutions is to provide quality web services and is among the few software development company in Australia.

    ReplyDelete
  3. Thank you for the very useful post. We will keep them in mind while we work.

    Megento Development Services In Chandigarh

    ReplyDelete
  4. Hello Kamlesh,

    Thanks for such a great post you have shared with us. I am searching for this source code only.
    Let me implement this.

    Thanks & Best Regards
    Hexagon | Magento Development Company India

    ReplyDelete
  5. Thanks for taking the time to discuss this, I feel strongly about it and love learning more on this topic. If possible, as you gain expertise, would you mind updating your blog with more information? It is extremely helpful for me.
    newizze.com

    ReplyDelete
  6. This comment has been removed by the author.

    ReplyDelete