Tape JIka
Tape JIka

Reputation: 31

Prestashop 1.7.8.8 Admin url from front office

I need to send from the front office admin URL: https://www.example.com/index.php?controller=AdminKbProductApprovalList.

The solution I've found is using, which generates the correct URL,but without admin folder and produces an error.

$this->context->link->getLegacyAdminLink('AdminKbProductApprovalList', false);

Warning: Use of undefined constant PS_ADMIN_DIR - assumed 'PS_ADMIN_DIR' (this will throw an Error in a future version of PHP) in /home/name/projects/asd.local/classes/Link.php on line 906.

How can I fix this?

Upvotes: 2

Views: 78

Answers (1)

Tape JIka
Tape JIka

Reputation: 31

What worked for me:

/* Getting controller URL */
$url = parse_url($this->context->link->getPageLink('Controller'));

/* Checking if the admin folder is set */
if (isset(glob(_PS_ROOT_DIR_ . '/admin*')[0])) {
    /* Changing the URL path to the admin folder name */
    $url['path'] = basename(glob(_PS_ROOT_DIR_ . '/admin*')[0]) . $url['path'];
}

/* Adding the modified URL to the email template variables using http_build_url */
$template_vars['{{redirect_url}}'] = http_build_url($url);

Upvotes: 1

Related Questions