Вопрос

I don't why my admin controller is not working, I have checked it and everything seems to be ok.

This is my code:

etc/adminhtml/routes.xml

<?xml version="1.0"?>

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
    <router id="admin">
        <route id="testpakke" frontName="testpakke">
            <module name="Company_Pakke" before="Magento_Backend" />
        </route>
    </router>
</config>

Controller/Adminhtml/Download/PDF.php

<?php

namespace Company\Pakke\Controller\Adminhtml\Download;
use Magento\Backend\App\Action;

class PDF extends Action
{
    /**
     * @var PageFactory
     */
    protected $resultPageFactory;

    /**
     * @param Context $context
     * @param PageFactory $resultPageFactory
     */

    public function __construct(
        \Magento\Backend\App\Action\Context $context,
        \Magento\Framework\View\Result\PageFactory $resultPageFactory
    ) {
        parent::__construct($context);
        $this->resultPageFactory = $resultPageFactory;
    }

    /**
     * Index action
     *
     * @return \Magento\Backend\Model\View\Result\Page
     */
    public function execute()
    {

        return  $resultPage = $this->resultPageFactory->create();
    }

}

when I type http://store/admin_1evvgb/testpakke/download or http://store/admin_1evvgb/testpakke/download/pdf or http://store/admin_1evvgb/testpakke/Adminhtml/download/pdf I get always the 404 error Page not found. Am I typing the path correctly?

Greetings!

Это было полезно?

Решение

It is naming convention issue. Please rename your controller action PDF to Pdf and run setup:upgrade and di : compile. And check route http://store/admin_1evvgb/testpakke/download/pdf

Hope it will help you.

Thank you

Лицензировано под: CC-BY-SA с атрибуция
Не связан с magento.stackexchange
scroll top