1

I have a file assume abc.php in multisite set up.

If I hit this using url :domain1.com/abc.php, I should get store name of domain1 and if I hit it using domain2.com/abc.php, I should get store name of domain2. I am using the below code:

$storeId = Mage::app()->getStore()->getName();

domain1.com being by default frontstore, when I hit domain2.com/abc.php I get store name of domain1 always. How do I get store specific information in a while placed in root folder?

2

You can try bellow code :

require_once("app/Mage.php");
echo Mage::app()->getStore()->getName(); 
  • Doesn't work :( – Twinkal Feb 9 '17 at 6:14
  • sorry I did not read your requirement properly. Actually this way you cannot get other store name except default store name . for this you have to set $_SERVER['MAGE_RUN_CODE'] and $_SERVER['MAGE_RUN_TYPE'] for each store. then you can use the above code to get store name. – Prasanta Hatui Feb 9 '17 at 6:21
  • How do I use it to keep it dynamic always? As in sometimes we may use website or store for run type...how do I always get the correct store name then? – Twinkal Feb 9 '17 at 7:10
  • If MAGE_RUN_TYPE is website then it gives default store name of that website and if MAGE_RUN_TYPE is store then it gives the current store name. For other than default store you have to pass the store code through url and set it as current store. – Prasanta Hatui Feb 9 '17 at 11:04
0

Try the below code in the start of your page

$magento_path = __DIR__;
require "{$magento_path}/app/Mage.php";

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.