2012-03-26 64 views
9

我目前工作的一个Magento站点是2种语言(法语和荷兰语)。我采用的方法如下: -Magento的集店铺标识编程

  • 在网站根目录(命名为NL)
  • 导入的index.php和.htaccess文件到该文件夹​​
  • 在索引创建一个文件夹。 PHP我修改下面一行:

    Mage::run('nl'); // to specify the store view i want to load 
    

当我检查,分类,CMS内容等等仍然是默认语言。以下代码: -

Mage::app()->getStore()->getName(); 

返回fr商店的名称。

它是什么,我做错了吗?我认为,一个可行的解决办法是设置商店的index.php中运行...

可能有人请让我知道如何通过ID加载一个店?

回答

26

经过数小时的吞吐和膨化我能够找出一种方式来设置店铺编号程序:)

在index.php文件中,(在你的语言特定的文件夹),添加以下内容: -

$store_id = 'your_store_id_here'; 
$mageRunCode = 'store view code'; 
$mageRunType = 'store'; 

Mage::app()->setCurrentStore($store_id); 
Mage::run($mageRunCode, $mageRunType); 

希望有人会发现此信息有用:)

+0

您节省了我的一天! :) – arekstasiewicz 2013-01-09 14:10:08

+1

+1'setCurrentStore()'是我一直在寻找的感谢! – 2013-07-02 20:39:09

+0

你能告诉我应该更新这段代码的位置吗? – Chiragit007 2013-09-17 10:08:54

5

您将得到所有细节店在这里

<?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; 
} 
?> 

重定向到指定的商店,你需要的页面与商店代码一起重定向。

http://www.mywebsite.com/index.php/store_code/

请检查模板/页/开关/了解更多详情

+0

感谢您的答复萨拉特,但还没t在管理员中启用了“将商店代码添加到网址”,因此上述功能无效。 – 2012-03-26 11:10:50

3

如果你正在做的东西htaccess的原因是,这样就可以产生具体到每家商店的网址stores.phtml,你可能想要配置选项,为你做,应该是在系统>配置>网络