I have followed many tutorials but im still getting a 404 error when trying to access with a custom menu item in my module.
This is what i have, : registration.php
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Digital_Custom',
__DIR__
);
etc/adminhtml/menu.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Backend:etc/menu.xsd">
<menu>
<add id="Digital_Custom::regenerate"
title="Digital Custom"
module="Digital_Custom"
sortOrder="9999"
action="importer/packadgeable/regenerate"
resource="Magento_Backend::content" />
</menu>
</config>
Here the new menu item is visible, but when click im getting 404
My controller Structure:
Digital - Custom - Controller - Adminhtml - Packadgeable - Regenerate.php This is my controller code Regenerate.php
<?php
namespace Digital\Custom\Controller\Adminhtml\Custom;
class Regenerate extends \Magento\Backend\App\Action
{
/**
* @var \Magento\Framework\View\Result\PageFactory
*/
protected $_resultPageFactory;
/**
* @param \Magento\Backend\App\Action\Context $context
* @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
*/
public function __construct(
\Magento\Backend\App\Action\Context $context,
\Magento\Framework\View\Result\PageFactory $resultPageFactory
)
{
parent::__construct($context);
$this->_resultPageFactory = $resultPageFactory;
}
/**
* Grid List page.
*
* @return \Magento\Backend\Model\View\Result\Page
*/
public function execute()
{
/** @var \Magento\Backend\Model\View\Result\Page $resultPage */
$resultPage = $this->_resultPageFactory->create();
$resultPage->getConfig()->getTitle()->prepend(__('Grid List'));
return $resultPage;
}
protected function _isAllowed() {
return true;
}
}
My route etc/adminhtml/routes.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/framework/App/etc/routes.xsd">
<router id="admin">
<route id="regenerate" frontName="regenerate">
<module name="Digital_Custom" before="Magento_Backend" />
</route>
</router>
</config>