0

Update:

Here is what the Developer Toolbar gives me on the 404 page:

Mode: Developer Controler
Module: Magento_Backend
Controler Class: Magento\Backend\Controller\Adminhtml\Noroute\Index
Controler Action Name: execute

Note the "Noroute" in the Class URI.

Original :

I'm creating my first Magento Module and My Index is working with a fully working filtering.

Index URL is :

http://local.com/admin/multiuseraccounts/permission/

I created the Edit action but the url trigger a 404 error :

Edit URL is :

http://local.com/admin/multiuseraccounts/permission/edit/permission_id/2

Here is my route.xml:

<router id="admin">
    <route id="multiuseraccounts" frontName="multiuseraccounts">
        <module name="Ramlam_MultiUserAccounts" before="Magento_Customer"/>
    </route>
</router>

Here is my module.xml

<module name="Ramlam_MultiUserAccounts" setup_version="1.0.0">
    <sequence>
        <module name="Magento_Customer"/>
    </sequence>
</module>

Index and Edit are in

Ramlam/MultiUserAccounts/Controller/Adminhtml/Permission/Index.php
Ramlam/MultiUserAccounts/Controller/Adminhtml/Permission/Edit.php

I deactivated the secure key but it didn't solve anything.

Index action is OK, Edit action triggers an error.

I tried every url combinaison possible

Magento never trigger the Edit class either xdebug nor die() is ever triggered in Edit class.

here is how the Edit url is built :

$this->urlBuilder->getUrl(
    'multiuseraccounts/permission/edit', 
    'permission_id' => $item['permission_id']]
);

Here is the acl:

 <acl>
     <resources>
        <resource id="Magento_Backend::admin">
            <resource id="Magento_Customer::customer">
                <resource id="Ramlam_MultiUserAccounts::multiuseraccounts" title="MultiUserAccounts" sortOrder="10" >
                    <resource id="Ramlam_MultiUserAccounts::multiuseraccounts_permission" title="Permission" sortOrder="40">
                        <resource id="Ramlam_MultiUserAccounts::multiuseraccounts_permission_save" title="Save" sortOrder="10" />
                        <resource id="Ramlam_MultiUserAccounts::multiuseraccounts_permission_delete" title="Delete" sortOrder="20" />
                    </resource>
                </resource>
            </resource>
        </resource>
    </resources>
</acl>

1 Answer 1

1

UPDATED

I'd structure it like this

Folder structure

Then your admin links should be like this

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="Xigen::top_level" module="Xigen_Customer" resource="Magento_Backend::content" sortOrder="9999" title="Xigen"/>
        <add action="customer/permission/edit" id="Xigen_Customer::permission_edit" module="Xigen_Customer" parent="Xigen::top_level" resource="Xigen_Customer::permission_edit" sortOrder="9999" title="permission edit"/>
        <add action="customer/permission/index" id="Xigen_Customer::permission_index" module="Xigen_Customer" parent="Xigen::top_level" resource="Xigen_Customer::permission_index" sortOrder="9999" title="permission index"/>
    </menu>
</config>

Other than that there is a backend helper for URLs

https://magento.stackexchange.com/a/210854/70343

Second Update

Edit controller looks like this

Controller/Adminhtml/Permission/Edit.php

<?php


namespace Xigen\Customer\Controller\Adminhtml\Permission;

class Edit extends \Magento\Backend\App\Action
{

    protected $resultPageFactory;

    /**
     * Constructor
     *
     * @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
    ) {
        $this->resultPageFactory = $resultPageFactory;
        parent::__construct($context);
    }

    /**
     * Execute view action
     *
     * @return \Magento\Framework\Controller\ResultInterface
     */
    public function execute()
    {
        echo 'edit';
        die();
        return $this->resultPageFactory->create();
    }
}

Other than that mot sure what to suggest. Pretty much built a working example here.

6
  • Why Index and not my Permission menu ? i will have to add more section like Permission, I can't put all in an Index folder. Thanks for the helper ! I will use that :)
    – iizno
    Jun 7, 2019 at 13:26
  • Fair point. Updated. Jun 7, 2019 at 13:40
  • My folder structure is like yours, so it should works, I don't understand
    – iizno
    Jun 7, 2019 at 13:50
  • One more edit. Best of luck. Jun 7, 2019 at 14:15
  • Edit Class is not even triggered in my case. At some point, I saw a: route='noroute' in xdebug
    – iizno
    Jun 7, 2019 at 14:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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