cancel
Showing results for 
Search instead for 
Did you mean: 

How to set website = 2 in below code

SOLVED

How to set website = 2 in below code

<?php
require_once('app/Mage.php'); //Path to Magento
umask(0);
Mage::app();
$methods = Mage::getSingleton('shipping/config')->getActiveCarriers();
$shipMethods = array();
foreach ($methods as $shippigCode=>$shippingModel)
{
$shippingTitle = Mage::getStoreConfig('carriers/'.$shippigCode.'/title');
$shipMethods[$shippigCode] = $shippingTitle;
}
echo "<pre>";
print_r($shipMethods);
?>
1 ACCEPTED SOLUTION

Accepted Solutions

Re: How to set website = 2 in below code

Hi @Aveeva,

You need to set store id instead of website id.

require_once('app/Mage.php'); //Path to Magento
umask(0);
Mage::app();

$defaultStoreId = Mage::app()
->getWebsite(2)
->getDefaultGroup()
->getDefaultStoreId();

Mage::app()->setCurrentStore($defaultStoreId);

I hope it will help you!

View solution in original post

4 REPLIES 4

Re: How to set website = 2 in below code

Hi @Aveeva,

You need to set store id instead of website id.

require_once('app/Mage.php'); //Path to Magento
umask(0);
Mage::app();

$defaultStoreId = Mage::app()
->getWebsite(2)
->getDefaultGroup()
->getDefaultStoreId();

Mage::app()->setCurrentStore($defaultStoreId);

I hope it will help you!

Re: How to set website = 2 in below code

@Vimal Kumar  May i know what is the difference 

$website_id = Mage::app()->getWebsite(2); vs  
$website_id = Mage::app()->getWebsite(2)->getDefaultGroup()->getDefaultStoreId();
 
in my prior case i just use only $website_id = Mage::app()->getWebsite(2),
 
eg :
$website_id = Mage::app()->getWebsite()->getId();
         if($website_id=="1")  
                       {
 
                                     //some code
                       }

 
 
but here $website_id = Mage::app()->getWebsite(2)->getDefaultGroup()->getDefaultStoreId(); only working, may i know what is the difference between these two concept?

Re: How to set website = 2 in below code

$website_id = Mage::app()->getWebsite(2);

It will return the website id 2 only.
vs

$website_id = Mage::app()->getWebsite(2)->getDefaultGroup()->getDefaultStoreId();

It will return the default storeid of the website which have website id =2

Re: How to set website = 2 in below code

Python
website = 1

# Your code here...
Use code with caution. 
content_copy

You can set the "website" variable to 2 by changing the code to:

Python
website = 2

# Your code here...
Use code with caution. 
content_copy
 
By KBH