magento以编程方式设置商店ID

magento以编程方式设置商店ID

本文介绍了magento以编程方式设置商店ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用两种语言(法语和荷兰语)的magento网站上工作.我采用的方法如下:

I am currently working on a magento site that is in 2 languages (French and Dutch). The approach I am taking is as follows:

  • 在Web根目录(名为nl)中创建一个文件夹
  • 将index.php和.htaccess文件导入该文件夹
  • 在index.php中,我修改以下行:

  • Create a folder in the web root (named nl)
  • Import the index.php and .htaccess file to that folder
  • In the index.php I modify the following line:

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

当我检查时,类别,CMS内容等仍为默认语言.以下代码:

When I check, the categories, CMS content etc are still in the default language. The following code:

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

返回fr商店的名称.

returns the fr store's name.

我做错了什么?我认为可行的解决方案是将商店设置为在index.php中运行...

What is it that I'm doing wrong? I think a viable solution would be to set the store to run in index.php...

有人可以让我知道如何通过ID加载商店吗?

Could someone please let me know how to load a store by ID?

推荐答案

经过数小时的喘气和喘气,我终于想出了一种以编程方式设置商店ID的方法:)

After hours of huffing and puffing i was able to figure out a way to set the store id programatically :)

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

In the index.php file, (in your language specific folder), add the following:-

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

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

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

Hope someone will find this information useful :)

这篇关于magento以编程方式设置商店ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 17:30