1

I am working on Magento 2 extension and I am facing below error.

a:4:{i:0;s:79:"Two 'add' commands cannot have equal id (Vendor_Mymodule::mymodule)";
i:1;s:6358:"#0 /home/mcs/html/demo/m2/Module/vendor/magento/module-backend/Model/Menu/Builder.php(43): 
Magento\Backend\Model\Menu\Builder\Command\Add->chain(Object(Magento\Backend\Model\Menu\Builder\Command\Add))

below is 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_Mymodule::mymodule_manager" title="mymodule" module="Vendor_Mymodule" parent="Vendor_General::general" sortOrder="10" resource="Vendor_Mymodule::mymodule_manager" />

        <add id="Vendor_Mymodule::mymodule" title="Manage Text" module="Vendor_Mymodule" sortOrder="11" parent="Vendor_Mymodule::mymodule_manager" action="mymodule/index" resource="Vendor_Mymodule::mymodule"/>

        <add id="Vendor_Mymodule::mymodule_data" title="Manage Data" module="Vendor_Mymodule" sortOrder="11" parent="Vendor_Mymodule::mymodule_manager" action="mymodule/index" resource="Vendor_Mymodule::mymodule"/>
    </menu>
</config>

Please help me resolve the issue.

  • Please post your menu.xml from your module – Keyur Shah Jun 8 '17 at 8:05
  • @KeyurShah, I added my menu.xml in question. – John Jun 8 '17 at 8:11
3

As per the error message, It looks like you have same id in menu.xml, you can see this error message on this file,

vendor\magento\module-backend\Model\Menu\Builder\Command\Add.php

public function chain(\Magento\Backend\Model\Menu\Builder\AbstractCommand $command)
{
    if ($command instanceof \Magento\Backend\Model\Menu\Builder\Command\Add) {
        throw new \InvalidArgumentException("Two 'add' commands cannot have equal id (" . $command->getId() . ")");
    }
    return parent::chain($command);
}

Please confirm your menu id is different or you have something wrong in menu.xml

  • Thanks, you were right. It was the issue with id of my menu item. – John Jun 8 '17 at 8:18

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.