Issue with Custom Admin Controller in PrestaShop 1.7.5.2: "The controller ExportStats is missing or invalid"

128 Views Asked by At

I'm facing an issue with a custom admin controller that I've created for my PrestaShop 1.7.5.2 website. The controller is supposed to be very simple and just display "Hello World" in the back-office. However, when I try to access the page, I get the error "The controller ExportStats is missing or invalid."

Environment:

-PrestaShop version: 1.7.5.2

-Local development machine running Ubuntu

What I've Done So Far:

-Created a file AdminExportStatsController.php in the controllers/admin directory of my PrestaShop installation.

-Here's the code for the controller:

<?php
if (!defined('_PS_VERSION_')) {
    exit;
}

class AdminExportStatsController extends AdminController
{
    public function __construct()
    {
        $this->bootstrap = true;
        $this->title = $this->l('Export Stats');

        parent::__construct();
    }

    public function initContent()
    {
        parent::initContent();
        $this->content .= $this->context->smarty->fetch('Hello World');
        $this->context->smarty->assign('content', $this->content);
    }
}

Registered this controller in PrestaShop's back-office by going to Advanced Parameters -> Menu and adding a new entry with "Sell" as the parent and ExportStats as the class name.

Issues Faced:

The menu does appear in the back-office under "Sell," but when I click on it, I get the aforementioned error. I've tried clearing the cache and checking permissions, but the issue persists. Strangely, I no longer see the menu entry under Advanced Parameters -> Menu, but it still shows up in the back-office.

My Question:

How can I resolve this issue and get my custom admin controller to work as expected?

Thank you in advance for your help!

0

There are 0 best solutions below