max*_* 69 10 php magento magento-1.4
我目前正在使用2种语言(法语和荷兰语)的magento站点.我采取的方法如下:
在index.php中我修改了以下行:
Mage::run('nl'); // to specify the store view i want to load
Run Code Online (Sandbox Code Playgroud)当我检查时,类别,CMS内容等仍然是默认语言.以下代码:
Mage::app()->getStore()->getName();
Run Code Online (Sandbox Code Playgroud)
返回fr商店的名称.
我做错了什么?我认为一个可行的解决方案是将商店设置为在index.php中运行...
有人可以让我知道如何通过ID加载商店吗?
max*_* 69 27
经过几个小时的喘息和喘气,我能够找到一种以编程方式设置商店ID的方法:)
在index.php文件中(在您的语言特定文件夹中),添加以下内容: -
$store_id = 'your_store_id_here';
$mageRunCode = 'store view code';
$mageRunType = 'store';
Mage::app()->setCurrentStore($store_id);
Mage::run($mageRunCode, $mageRunType);
Run Code Online (Sandbox Code Playgroud)
希望有人会发现此信息有用:)
您将在此处获取所有商店详细信息
<?php
$allStores = Mage::app()->getStores();
foreach ($allStores as $_eachStoreId => $val)
{
$_storeCode = Mage::app()->getStore($_eachStoreId)->getCode();
$_storeName = Mage::app()->getStore($_eachStoreId)->getName();
$_storeId = Mage::app()->getStore($_eachStoreId)->getId();
echo $_storeId;
echo $_storeCode;
echo $_storeName;
}
?>
Run Code Online (Sandbox Code Playgroud)
要重定向到指定的商店,您需要将页面与商店代码一起重定向.
http://www.mywebsite.com/index.php/store_code/
请查看template/page/switch/stores.phtml以获取更多详细信息