2012-03-26 66 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,你可能想要配置選項,爲你做,應該是在系統>配置>網絡