0

I have been struggling with this error all day, I have tried all the solutions on Internet, but it keeps showing 404 Error when I click the link on my custom menu.

Here is my code

/app/code/Vendor/Module/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="Vendor_Module::menu" title="Sift Science" module="Vendor_Module" sortOrder="51" resource="Vendor_Module::menu"/>
        <add id="Vendor_Module::menu_item" title="Configuration" module="Vendor_Module" sortOrder="10" parent="Vendor_Module::menu" action="SiftMenu/ConfigMenu/" resource="Vendor_Module::menu_item"/>
    </menu>
</config>

Controller /app/code/Vendor/Module/Controller/Adminhtml/ConfigMenu/SiftSetup.php

<?php

namespace Vendor\Module\Controller\adminhtml\configmenu;



use \Magento\Backend\App\Action;
use \Magento\Backend\App\Action\Context;
use Magento\Framework\View\Result\PageFactory;
use \Magento\Framework\Json\Helper\Data;

class SiftSetup extends Action
{
    protected $resultPageFactory;
    protected $jsonHelper;

    public function __construct(Context $context, PageFactory $pageFactory, Data $jsonHelper )
    {
        $this->resultPageFactory = $pageFactory;
        $this->jsonHelper = $jsonHelper;
        parent::__construct($context);
    }

    public function execute()
    {


        die ("test module");


    }
}

routes.xml /app/code/Vendor/Module/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="standard">
        <route id="SiftMenu" frontName="SiftMenu">
            <module name="Vendor_Module" />
        </route>

    </router>
</config>
3

You first should change the namespace for controller's action

namespace Vendor\Module\Controller\Adminhtml\ConfigMenu; //Capital for first letter

You should change your action in the menu.xml:

<add id="Vendor_Module::menu_item" 
    title="Configuration" module="Vendor_Module" sortOrder="10" 
    parent="Vendor_Module::menu" 
    action="siftMenu/configMenu/siftSetup"    #full controller-action pattern
    resource="Vendor_Module::menu_item"/> 

You also need to change the routes.xml in etc/adminhtml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
    <router id="admin"> <!-- admin -->
        <route id="SiftMenu" frontName="SiftMenu">
           <module name="Vendor_Module"/>
         </route>
     </router>
</config>
  • hello, it's still not working, I changed capital for first letter on route and controller folder. action="SiftMenu/ConfigMenu/SiftSetup" and namespace Transom\SiftScienceModule\Controller\Adminhtml\ConfigMenu; – Oscar Vazquez Sep 19 at 22:48
  • <router id="admin"> instead of <router id="standard"> – Jeff Yu Sep 19 at 22:50
  • Oh it works now! thank you very much, I did not notice that – Oscar Vazquez Sep 19 at 22:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.