只有登录的客户才能访问OC中的页面


only logged in customer should access a page in oc

我想在某些条件下显示一个信息页面,例如 1. 客户组 ID 为 2 2. 客户已登录

如果满足这两个条件,则显示信息页面(id-12) 课程 1。

我正在尝试在目录/控制器/信息中执行此操作.php

$id = $this->customer->getGroupId();
if (($this->customer->isLogged()) &&  ($information_id == 12) && ($id==2)) { 
    $this->redirect($this->url->link('account/account', '', 'SSL'));    
}

但这不起作用,给出错误致命错误:调用未定义的方法控制器信息信息::重定向()

我哪里出错了。请建议

使用 $this->response->redirect($this->url->link('account/account', '', 'SSL'));
而不是$this->redirect($this->url->link('account/account', '', 'SSL'));

编辑
redirect()方法在 class Response 中定义。仅当在当前类中定义了redirect()方法时,才能执行$this->redirect()操作。

编辑 2

如果您只想向登录客户显示信息页面,请尝试此条件

if (!$this->customer->isLogged()) {
    $this->response->redirect($this->url->link('account/login', '', 'SSL'));
}

只是把它放在之后

public function index() {  ...