Force redirect to login page for category if category is only assigned to customers (loggedin users) Prestashop


In Prestashop, if category is only assigned to customers (loggedin users) then you will see an error message on that category Page that state:

'You do not have access to this category.'

To Force your users to redirect at login page, you have to modify your CategoryController.php file.

Copy file from controllers/front/CategoryController.php and paste into

override/controllers/front/CategoryController.php

Now, inside init function find

if (!$this->category->checkAccess($this->context->customer->id)) {

Remove all code inside this condition and write below code to redirect it to myaccount page:

Tools::redirect('index.php?controller=authentication?back=my-account');



if (!$this->category->checkAccess($this->context->customer->id)) {

Tools::redirect('index.php?controller=authentication?back=my-account');

}

Post a Comment

0 Comments