Opencart Multi Store - 将其中一个商店重定向到帐户/登录

时间:2012-08-29 06:16:42

标签: php opencart

我使用的是Opencart 1.5.4.1版,我已经安装了商店模块&下拉列表中有3个商店(例如默认值,Store1,Store2)。

我的要求是将最后一个商店(示例Store2)重定向到account/login

我尝试将\catalog\controller\module\store.php中的路径从index.php?route=common/home修改为index.php?route=account/login,但Store1和& Store2被重定向到account/login

我还尝试使用以下if条件:如果我从默认选择Store1& Store1到Store2,它正常工作,但是如果从默认选择Store2,它就无法正常工作。

foreach ($results as $result) {
    if((int)$this->config->get('config_store_id')==1)
    {
        $this->data['stores'][] = array(
            'store_id' => $result['store_id'],
            'name'     => $result['name'],
            'url'      => $result['url'] . 'index.php?route=account/login'
        );
    }
    else
    {
        $this->data['stores'][] = array(
            'store_id' => $result['store_id'],
            'name'     => $result['name'],
            'url'      => $result['url'] . 'index.php?route=common/home'
        );
    }
}

1 个答案:

答案 0 :(得分:0)

您可以使用以下vqmod code

  1. 将其复制到扩展名为.xml的文件。
  2. 将其上传到vqmod\xml文件夹。
  3. 商店ID设置为1,如果商店编号不同,请进行更改。

  4. <modification>
        <id>Force Customer Login</id>
        <version>152.1</version>
        <vqmver>2.1.5</vqmver>
        <author>Qphoria</author>
        <file name="catalog/controller/common/header.php">
            <operation>
                <search position="after"><![CDATA[function index()]]></search>
                <add trim="true">
                    <![CDATA[//Q: Force Customer Login
                        $match = false;
                        if (!empty($this - > request - > get['route'])) {
    
                            $skip = array(
                                'payment',
                                'feed',
                                'forgotten',
                                'login',
                                'register', );
    
                            foreach($skip as $s) {
                                if (strpos($this - > request - > get['route'], $s) !== false) {
                                    $match = true;
                                    break;
                                }
                            }
                        }
    
                        if (!$match) {
                            if (!$this - > customer - > isLogged()) {
                                if ($this - > config - > get('config_store_id') == 1) {
                                    $this - > redirect($this - > url - > link('account/login', 'SSL'));
                                }
                            }
                        }
                    ]]>
                </add>
            </operation>
        </file>
    </modification>
    
相关问题