0

Hi my custom menu not showing admin user role.

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="Retailers_Company::retailers" title="Retailers" module="Retailers_Company" sortOrder="10" resource="Retailers_Company::retailers"/>
    <add id="Retailers_Company::add_new" title="Retailers Account Management" module="Retailers_Company" sortOrder="20" parent="Retailers_Company::retailers" action="company/vendor" resource="Retailers_Company::add_new"/>
    <add id="Retailers_Company::add" title="Add Account Manager" module="Retailers_Company" sortOrder="20" parent="Retailers_Company::retailers" action="company/index/add" resource="Retailers_Company::add"/>
    <add id="Retailers_Company::account" title="View Account Manager" module="Retailers_Company" sortOrder="20" parent="Retailers_Company::retailers" action="company/index/account" resource="Retailers_Company::account"/>
    <!--<add id="Retailers_Company::parent" title="Company" module="Retailers_Company" sortOrder="100" resource="Retailers_Company::parent"/>
    <add id="Retailers_Company::index" title="Company Index" module="Retailers_Company" sortOrder="10" action="company/index" resource="Retailers_Company::index" parent="Retailers_Company::parent"/>-->
    <!--<add id="Retailers_Company::add_row" title="Retailers Account Management" module="Retailers_Company" sortOrder="20" parent="Retailers_Company::retailers" action="company/company" resource="Retailers_Company::add_row"/>-->
</menu>
</config>

etc/adminhtml/acl.xml

<?xml version="1.0"?>
 <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
 <acl>
    <resources>
        <resource id="Magento_Backend::admin">
            <resource id="Retailers_Company::sample" title="Retailers" sortOrder="10" >
                <resource id="Retailers_Company::items" title="Retailers Account Management" sortOrder="20" />
            </resource>
        </resource>
    </resources>
  </acl>
</config>

Index.php(controller)

<?php
 namespace Retailers\Company\Controller\Adminhtml\Vendor;

 class Index 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->setActiveMenu('Retailers_Company::items');
    $resultPage->getConfig()->getTitle()->prepend(__('Retailers Account Management'));

    return $resultPage;
}

/**
 * Check Grid List Permission.
 *
 * @return bool
 */
protected function _isAllowed()
{
    return $this->_authorization->isAllowed('Retailers_Company::items');
}
}

enter image description here

0

This should fix your issue

<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
    <acl>
        <resources>
            <resource id="Magento_Backend::admin">
                <resource id="Magento_Backend::stores">
                    <resource id="Magento_Backend::stores_settings">
                        <resource id="Magento_Config::config">
                            <resource id="Retailers_Company::items" title="Retailers Account Management" sortOrder="20" />
                        </resource>
                    </resource>
                </resource>
            </resource>
        </resources>
    </acl>
</config>
  • Thank you for replaying. I update this code on acl file but nothing to happend. – Rajesh Nagappan Sep 22 '17 at 6:03
  • Did you rerun setup upgrade – Dava Gordon Sep 22 '17 at 14:32
  • Yes but nothing to happend – Rajesh Nagappan Sep 26 '17 at 8:28
  • In this acl file how to get my custom menu? Because in this acl file did't define my custom menu Id – Rajesh Nagappan Sep 26 '17 at 8:36
  • can you please post your full script so can see the issue – Dava Gordon Sep 26 '17 at 9:03

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.