8

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

21

Like this:

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

Or do a direct database lookup on the core_store table.

| improve this answer | |
13

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

Mage::app()->getStore()->getWebsiteId(); 
| improve this answer | |
6

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

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

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

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

| improve this answer | |

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.