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.
Mage::app()->getStore()->getWebsiteId(); this will return the website id for current store.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With