0

I have created a custom grid module in magento 2, It created a menu in admin panel, on click of menu, it is redirecting to dashboard and system.log has following errors :

...
[2017-07-01 04:11:57] main.INFO: Cache file with merged layout: LAYOUT_adminhtml_STORE1_391fccd54da687afc76a5d6559b714906 and handles default, adminhtml_dashboard_index: Please correct the XML data and try again.  [] []
[2017-07-01 04:11:57] main.INFO: Cache file with merged layout: LAYOUT_adminhtml_STORE1_3cf9ab1b1723bedc1dcd665a812b00335 and handles admin-1column: Please correct the XML data and try again.  [] []
[2017-07-01 04:11:57] main.CRITICAL: Broken reference: the 'header' tries to reorder itself towards 'global.notices', but their parents are different: 'page.wrapper' and 'notices.wrapper' respectively. [] []
[2017-07-01 04:11:57] main.CRITICAL: Broken reference: the 'page.breadcrumbs' tries to reorder itself towards 'notifications', but their parents are different: 'page.wrapper' and 'notices.wrapper' respectively. [] []
[2017-07-01 04:11:57] main.CRITICAL: Broken reference: the 'global.search' tries to reorder itself towards 'notification.messages', but their parents are different: 'header.inner.right' and 'header' respectively. [] []
[2017-07-01 04:11:59] main.INFO: Cache file with merged layout: LAYOUT_adminhtml_STORE1_36f1b068ec7ccf4878f9284dd1137afd1 and handles catalog_product_prices: Please correct the XML data and try again.  [] []
...

My menu.xml file is :

<?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="Company_Custom::manager" title="Grid Manager" module="Company_Custom" sortOrder="10" resource="Company_Custom::manager"/>
        <add id="Company_Custom::add_row" title="Grid Manager" module="Company_Custom" sortOrder="20" parent="Company_Custom::manager" action="company_custom/custom/index" resource="Magento_Backend::content"/>
    </menu>
</config>

And routes.xml is :

<?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="company_custom" frontName="company_custom">
            <module name="Company_Custom" before="Magento_Backend" />
        </route>
    </router>
</config>

Why is it redirecting to dashboard?

7
  • May Be check your Xml, in xml You have not configured right controller paths Commented Jul 1, 2017 at 4:23
  • Try to put your action as custom/custom/index . Commented Jul 1, 2017 at 4:26
  • Hi @PranayK, please check my edited question. Commented Jul 1, 2017 at 4:29
  • Hi @DineshYadav, I tried that, but not working. Commented Jul 1, 2017 at 4:30
  • Your controller might have some problem. Have you tried echo something and exit in your controller ? Commented Jul 1, 2017 at 4:33

1 Answer 1

0

I think you need to change "Controllers" to "Controller" then check

Change: Company/Custom/Controller/Adminhtml/Custom/Index.php

<?php
namespace Company\Custom\Controller\Adminhtml\Custom;

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->getConfig()->getTitle()->prepend(__('Grid List'));

    return $resultPage;
}

}

0

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.