Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get website id using Order Object in Magento

Tags:

php

magento

I want to get the website id using a Sales/Order object in Magento.

I tried the code below. But it is not working.

$order = Mage::getModel('sales/order')->getCollection();
foreach($order as $o){
  //Here i want to get store id and website id 
  echo $o->getStoreName();
  echo $o->getStoreId();
  echo $o->getWebsiteId();

}

Store id works as expected. But the website id is reported as null.

Please suggest any other way, which works.

like image 516
Dixit Patel Avatar asked Jul 18 '14 12:07

Dixit Patel


People also ask

How do I find the site ID in Magento 2?

Mage::app()->getStore()->getWebsiteId(); this will return the website id for current store.

How do you find a website ID?

Click on the Measurables(or Websites) > Manage page. You will find a list of all websites on this page. The website ID is on the left of the table listing all websites directly below the website name.

How can I get last order ID in Magento 2?

You can fetch Last order id of order by Magento\Checkout\Model\Session Object. Call method to get last order id using below way, $orderId = $this->checkoutSession->getData('last_order_id'); $orderId is your recent order id for a store.


1 Answers

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

The above code should get the website id of the store that your order was placed in.

like image 142
GaryDevenay Avatar answered Oct 01 '22 20:10

GaryDevenay