Jump to content

How to redirect to all products after sign in


ludojlm

Recommended Posts

Hi, 

I'm looking for a way to redirect to the All products page when sign in. I found where the redirection is done, in the MyAccountController.php :

class MyAccountControllerCore extends FrontController
{
    public $auth = true;
    public $php_self = 'my-account';
    public $authRedirection = '';
    public $ssl = true;

    /**
     * Assign template vars related to page content
     * @see FrontController::initContent()
     */
    public function initContent()
    {
        $this->context->smarty->assign([
            'logout_url' => $this->context->link->getPageLink('index', true, null, 'mylogout')
        ]);

        parent::initContent();
        $this->setTemplate('customer/my-account');
    }
}

I have to put something in the public $authRedirection ="". 

I found a list of keywords I can put (my-account, index...), I also managed to put new-products, but I want the link to all. It is the category 2, but I can't link it. 

Does anyone know how to do it? Thanks in advance!

Link to comment
Share on other sites

In AuthController.php file, where the login takes place, search for function processSubmitAccount():

Almost at the end, find these lines:

                        // else : redirection to the account
                        else {
                            Tools::redirect('index.php?controller='.(($this->authRedirection !== false) ? urlencode($this->authRedirection) : 'my-account'));
                        }

So if something is defined as authRedirection - then it will redirect you to 'index.php?controller='.urlencode($this->authRedirection).

 

For your case, add 

public $authRedirection = 'category&id_category=2';

to the beginning of the Auth controller and it should work.

 

Link to comment
Share on other sites

Thanks, but I still have a bug : the redirected URL doesn't give me index.php?controller=category&id_category=2, but connexion?back=category&id_category=2

I can't also find no function named processSubmitAccount() in the whole project. I am on Prestashop 1.7.4.4, if that helps.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...