8

Given a store id, how do I get the website id that matches that store?

4 Answers 4

22

Like this:

Mage::getModel('core/store')->load($storeId)->getWebsiteId()

Or do a direct database lookup on the core_store table.

14

Just for completeness: From the current store you're in, you could retrieve the websiteId as follows:

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

In Magento 2 to you can find the Website Id using store id like this:

$this->_storeManager->getStore($storeID)->getWebsiteId();

9
  • Magento 1 Inside the phtml file how to get website id? thanks @Faisal Sheikh
    – Gem
    Mar 17, 2020 at 9:55
  • @Gem Do you want current website id or all website ids? Mar 17, 2020 at 10:46
  • My condition : if website_id == 2 { hello} else { hi }
    – Gem
    Mar 17, 2020 at 10:49
  • I just want to put inside my app/locale/en_US/template/email/sales/order_new.html
    – Gem
    Mar 17, 2020 at 10:51
  • My Code: paste.ofcode.org/GKsBaztggNpXrmSws7cEyG line 30 - 40
    – Gem
    Mar 17, 2020 at 10:58
0

If you have database access you can directly check website id in store_website table

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.