2012-04-07 41 views
0

我正在构建prestashop目录,但只有登录到客户才能看到它。这可能吗。这将是很好,如果内置prestashop登录用于此..任何帮助表示赞赏。仅登录prestashop目录

+0

这可能工作其昂贵,虽然:([链接](http://www.presto-changeo.com/en/prestashop-modules/30-private-shop.html) – rashid 2012-04-10 07:47:57

回答

1

这很容易。

使用此代码:

if(!self::$cookie->isLogged(true) AND in_array($this->step, array(1, 2, 3))) 
    Tools::redirect('authentication.php'); 

在你indexController的的预处理

+0

谢谢,得到它的工作没有in_array ()部分,w是什么意思btw? – rashid 2012-05-09 10:11:12

+0

还有一件事,这只适用于客户访问主页时,所有其他页面通过直接链接工作访问 – rashid 2012-05-09 10:43:30

1

这里是我的解决方案,它的工作原理就像一个魅力,是一个非常简单的办法!

在类\的configuration.php(左右线114),它看起来像这样

static public function get($key, $id_lang = NULL) 
{ 
    if ($id_lang AND isset(self::$_CONF_LANG[(int)$id_lang][$key])) 
     return self::$_CONF_LANG[(int)$id_lang][$key]; 
    elseif (is_array(self::$_CONF) AND key_exists($key, self::$_CONF)) 
     return self::$_CONF[$key]; 
    return false; 
} 

它改成这样:

static public function get($key, $id_lang = NULL) 
{ 
    //Grab access to the $cookie which is already loaded in the FrontController as global $cookie; 
    global $cookie; 
    if ($id_lang AND isset(self::$_CONF_LANG[(int)$id_lang][$key])) 
     return self::$_CONF_LANG[(int)$id_lang][$key]; 
    elseif (is_array(self::$_CONF) AND key_exists($key, self::$_CONF)) 
     //If the system is trying to find out if Catalog Mode is ON, then return the configuration setting, 
     //but override it with the user logon status 
     if($key == 'PS_CATALOG_MODE') 
     { 
      return !$cookie->logged || self::$_CONF[$key]; 
     } 
     else 
     { 
      return self::$_CONF[$key]; 
     } 
    return false; 
} 

从本质上讲,我想强制系统显示“目录模式“,并在他登录时关闭此功能。

我可以保证这适用于v1.4.3.0和当前版本1.4.8.2的代码(在这篇文章的时间)没有改变,所以它应该在那里工作。

+0

非常感谢,早期的解决方案只适用于索引/ home页面,把它放在配置中更有意义! – rashid 2012-07-04 11:36:10

+0

我想带人login.php,如果他们没有登录,并且没有显示目录模式或任何东西,直到登录。 – rashid 2012-11-07 11:07:26

+0

很好的答案!谢谢你的分享。 – JazZ 2016-04-02 18:48:53

2

我有一个建议。您可以使用PrestaShop 1.5中的客户组功能,并且只允许登录的客户查看价格。对于分组在访客中的每个客户,他们都会在目录模式下看到您的网站。

2

的Prestashop 1.5解决方案:

只需上传原始文件:

classes\controller\FrontController.php 

到:

override/classes/controller/FrontController.php 

接下来,命名类。最终的代码应该是这样的:

class FrontController extends FrontControllerCore 
{ 
    public function init() 
    { 
     parent::init(); 
     if (!$this->context->customer->isLogged() && $this->php_self != 'authentication' && $this->php_self != 'password') 
     { 
      Tools::redirect('index.php?controller=authentication?back=my-account'); 
     } 
    } 
} 

最后一步是手动删除下列文件,以便的Prestashop是意识到被覆盖的类(它会自动重新生成)的:

cache/class_index.php 

而且voilà,在不覆盖核心文件的情况下实现了功能。