I have created a command the class is Vendor\CreateProduct\Command\CreateProduct. It could be found when I type: php bin/magento

But when I create another command which class is Vendor\CreateProduct\Command\UpdateProduct. It could not be found when I type: php bin/magento.

The di.xml is like follows:

<?xml version="1.0"?>
    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
        <type name="Magento\Framework\Console\CommandList">
                  <argument name="commands" xsi:type="array">
                      <item name="vendor_createproduct_command_createproduct" xsi:type="object">Vendor\CreateProduct\Command\CreateProduct</item>
                      <item name="vendor_createproduct_command_updateproduct" xsi:type="object">Vendor\CreateProduct\Command\UpdateProduct</item>

Can anyone help this?


the string in setName function is $this->setName("zhouzi:product:update") and $this->setName("zhouzi:product:create");

  • What name are you giving in setName function un UpdateProduct.php File – Amrit Pal Singh Oct 29 '19 at 7:21
  • Both are listing at my end. Have you tried setup:upgrade and setup:di:compile? – Amrit Pal Singh Oct 29 '19 at 13:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.