36

Can someone please explain this error to me?

Exception #0 (Exception): Notice: Undefined index: id in /home/staging/vendor/magento/module-config/Model/Config/Structure/Element/Iterator.php on line 59
    #0 /home/staging/vendor/magento/module-config/Model/Config/Structure/Element/Iterator.php(59): Magento\Framework\App\ErrorHandler->handler(8, 'Undefined index...', '/home/asconveyo...', 59, Array)
    #1 /home/staging/vendor/magento/module-config/Model/Config/Structure.php(92): Magento\Config\Model\Config\Structure\Element\Iterator->setElements(Array, 'default')
    #2 /home/staging/var/generation/Magento/Config/Model/Config/Structure/Interceptor.php(24): Magento\Config\Model\Config\Structure->getTabs()
    #3 /home/staging/vendor/magento/module-config/Model/Config/Structure.php(135): Magento\Config\Model\Config\Structure\Interceptor->getTabs()
    #4 /home/staging/var/generation/Magento/Config/Model/Config/Structure/Interceptor.php(63): Magento\Config\Model\Config\Structure->getFirstSection()
    #5 /home/staging/vendor/magento/module-config/Controller/Adminhtml/System/AbstractConfig.php(57): Magento\Config\Model\Config\Structure\Interceptor->getFirstSection()
    #6 /home/staging/vendor/magento/framework/Interception/Interceptor.php(74): Magento\Config\Controller\Adminhtml\System\AbstractConfig->dispatch(Object(Magento\Framework\App\Request\Http))
    #7 /home/staging/vendor/magento/framework/Interception/Chain/Chain.php(70): Magento\Config\Controller\Adminhtml\System\Config\Index\Interceptor->___callParent('dispatch', Array)
    #8 /home/staging/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Config\\...', 'dispatch', Object(Magento\Config\Controller\Adminhtml\System\Config\Index\Interceptor), Array, 'adminAuthentica...')
    #9 /home/staging/vendor/magento/module-backend/App/Action/Plugin/Authentication.php(143): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
    #10 /home/staging/vendor/magento/framework/Interception/Chain/Chain.php(67): Magento\Backend\App\Action\Plugin\Authentication->aroundDispatch(Object(Magento\Config\Controller\Adminhtml\System\Config\Index\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
    #11 /home/staging/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Config\\...', 'dispatch', Object(Magento\Config\Controller\Adminhtml\System\Config\Index\Interceptor), Array, 'adminMassaction...')
    #12 /home/staging/vendor/magento/module-backend/App/Action/Plugin/MassactionKey.php(33): Magento\Config\Controller\Adminhtml\System\Config\Index\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
    #13 /home/staging/vendor/magento/framework/Interception/Interceptor.php(142): Magento\Backend\App\Action\Plugin\MassactionKey->aroundDispatch(Object(Magento\Config\Controller\Adminhtml\System\Config\Index\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
    #14 /home/staging/var/generation/Magento/Config/Controller/Adminhtml/System/Config/Index/Interceptor.php(39): Magento\Config\Controller\Adminhtml\System\Config\Index\Interceptor->___callPlugins('dispatch', Array, Array)
    #15 /home/staging/vendor/magento/framework/App/FrontController.php(55): Magento\Config\Controller\Adminhtml\System\Config\Index\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
    #16 /home/staging/vendor/magento/framework/Interception/Interceptor.php(74): Magento\Framework\App\FrontController->dispatch(Object(Magento\Framework\App\Request\Http))
    #17 /home/staging/vendor/magento/framework/Interception/Chain/Chain.php(70): Magento\Framework\App\FrontController\Interceptor->___callParent('dispatch', Array)
    #18 /home/staging/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'install')
    #19 /home/staging/vendor/magento/framework/Module/Plugin/DbStatusValidator.php(69): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
    #20 /home/staging/vendor/magento/framework/Interception/Interceptor.php(142): Magento\Framework\Module\Plugin\DbStatusValidator->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
    #21 /home/staging/var/generation/Magento/Framework/App/FrontController/Interceptor.php(26): Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', Array, Array)
    #22 /home/staging/vendor/magento/framework/App/Http.php(135): Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
    #23 /home/staging/vendor/magento/framework/App/Bootstrap.php(258): Magento\Framework\App\Http->launch()
    #24 /home/staging/index.php(42): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http))
    #25 {main}
3
  • Hi, Have you installed any new extension?
    – Meetanshi
    Nov 22, 2017 at 8:52
  • May be error in your module xml(system.xml, acl.xml, etc..) paste your code if you can. Nov 22, 2017 at 8:56
  • Having same issue, after installing github.com/mageplaza/magento-2-better-popup extension by downloading. But when install via composer it works fine. I need to change its functionality that is why can not install by composer. Anybody have solve this ?
    – Ajwad Syed
    Nov 14, 2018 at 9:33

9 Answers 9

45

I have faced a similar issue and in my case, the issue was because I have incorrect tab id matching in system.xml

<tab id="custom_tab" translate="label" sortOrder="2000">
            <label>Custom Tab</label>
        </tab>
        <section id="custom_section" translate="label" type="text" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1">
            <class>separator-top</class>
            <label>Custom Section</label>
            <tab>customtab</tab>

To fix the issue, I changed
<tab>customtab</tab>
to
<tab>custom_tab</tab>

2
  • Hi @Anshu Mishra the above answer is helped for me, but when i disble the module from admin side its not disablinhg. Dec 28, 2018 at 6:41
  • Also worth checking that a module you think is enabled is actually present and enabled, that would also trigger a referenced tab ID to not exist. In my case a missing submodule was the culprit. Mar 27, 2023 at 12:07
39

One easy way to debug is: browse and open vendor/magento/module-config/Model/Config/Structure/Element/Iterator.php

change

public function setElements(array $elements, $scope)
    {
        $this->_elements = $elements;
        $this->_scope = $scope;
        if (count($elements)) {
            $lastElement = end($elements);
            $this->_lastId = $lastElement['id'];
        }
    }

to

public function setElements(array $elements, $scope)
    {
        $writer = new \Zend\Log\Writer\Stream(BP . '/var/log/config_debug.log');
        $logger = new \Zend\Log\Logger();
        $logger->addWriter($writer);
        
        $this->_elements = $elements;
        $this->_scope = $scope;
        
        if (count($elements)) {
            $lastElement = end($elements);

            // Log last Element
            $logger->info($lastElement);

            $this->_lastId = $lastElement['id'];
        }
    }

Reload browser configuration window and see once again the error.

Check var/log/config_debug.log file.

Go to very bottom of the file and see which module failed, where it stopped.

That's the one causing your issues.

Don't forget to rollback your changes once fixed.

2
19

In my case, I have installed ​ https://www.mageplaza.com/magento-2store-credit/ extension, but did not installed core module of Mageplaza.

I found that <tab>mageplaza</tab> mentined in system.xml but tab is not defined in this file. So, installed core module for Mageplaza from https://github.com/mageplaza/module-core and it's working fine.

2
  • Thanks @nalin savaliya Oct 14, 2019 at 12:36
  • 2
    Same here, except that I had the module installed through Composer, but it wasn't enabled. bin/magento module:enable Mageplaza_Core fixed that. Jan 27, 2020 at 11:52
8

I met the same error and figured out that it lost the tab tag in app/code/CompanyName/ExtensionName/etc/adminhtml/system.xml.

For example, you have to add

<tab id="amasty" translate="label" sortOrder="999999" class="amasty-tab ambase-tab-container">
    <label>Amasty Extensions</label>
</tab>

in app/code/Amasty/SeoSingleUrl/etc/adminhtml/system.xml between the system and section tag like this.

<system>
    <tab id="amasty" translate="label" sortOrder="999999" class="amasty-tab ambase-tab-container">
        <label>Amasty Extensions</label>
    </tab>        
    <section id="amasty_seourl" translate="label" type="text" sortOrder="190519" showInDefault="1" showInWebsite="1"
             showInStore="1">
        <label>SEO Single URL</label>
7

In my case the error thrown because the tab was defined in the module which is disabled, but used in another module which is enabled. So, I recommend you to check which tab have no id in the specified class:

debug example

Then, search that name by entire project (in the system.xml file) and check is that module enabled.

PS: there is no error on the screenshot, but actually it was fired by the DeliveryTime module, because Core module was disabled when I tried to access store configuration page.

1

I have also face this issue in magento2. This is my system.xml file


<tab id="cnet" translate="label" sortOrder="10">
            <label>CNET</label>
        </tab>
        <section id="cnet" translate="label" sortOrder="130" showInDefault="1" showInWebsite="1" showInStore="1">
            <class>separator-top</class>
            <label>General Information</label>
            <tab>cnet</tab>

Please change tab id = "cnet" and cnet. If its not matching error will be occur. After change this one run the "sudo php bin/magento setup:di:compile"

0

This issue is coming because of system.xml. Please correct as per below, your system tab id="custom_tab" translate="label" sortOrder="10"> And tab name under section should be same.

0

This happend to me because I was referring to a tab that did not exist yet.

<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
    <system>
        <section id="company_app" sortOrder="10" showInWebsite="1" showInStore="1" showInDefault="1" translate="label">
            <label>Company App</label>
            <tab>company</tab>
            <resource>Company_App::config_company_app</resource>
            ...

Solution:

<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
    <system>
        <tab id="company" translate="label" sortOrder="1">
            <label>Company</label>
        </tab>
        <section id="company_app" sortOrder="10" showInWebsite="1" showInStore="1" showInDefault="1" translate="label">
            <label>Company App</label>
            <tab>company</tab>
            <resource>Company_App::config_company_app</resource>
            ...
0

The reason that you have encountered this issue is because of your "system.xml" file.

I faced similar issue because of mismatch of tab id.

<system>
   <tab id="magedelight" translate="label" sortOrder="200"> // tab  id
           <label>Magedelight</label>
        </tab>
        <section id="magedelight" translate="label" sortOrder="150" showInDefault="1" showInWebsite="1" showInStore="1">
       <class>separator-top</class>
       <label>Crud</label>
       <tab>magedelight</tab> // This should match tab id at line no. 2
</section>
</section>

Quick but not recommended solution:-

 public function setElements(array $elements, $scope)
    {
        $this->_elements = $elements;
        $this->_scope = $scope;
        if (count($elements)) {
            $lastElement = end($elements);
            $this->_lastId =!empty($lastElement['id'])?$lastElement:"1";
        }
    }

Hope this helps.

New contributor
Sahil Arora is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

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.