Read More
Read More
Menu Close

    How to create custom command to delete order in magento2

    How to create custom command to delete order in magento2 – In Magento 2  you can create your own custom command for any action. As magento doesn’t allow to delete order from admin dashboard then in this case there comes a need for how to delete orders. So here using this post I am going to explain how to create your own custom command for deleting magento order.

    For this you just need to follow some easy steps-

    1. Create a Command class in the path<module_dir>/Console/Command (As recommended by magento), like here I am using the path app/code/Webkul/CustomCommand/Console/Command
    2. Declaration of Command class in Magento\Framework\Console\CommandList using dependency injection in file path “app/code/Webkul/CustomCommand/di.xml”
    3. Now clear the cache and compile the module.
    4. Now run the following command to check the working process of this commands-
      php bin/magento –list
      now you will see the custom created command as shown in the given screenshotKqikiDw
      Now run command – php bin/magento webkul:orderDelete 1 to delete order with order id 1 through command line. gj7sQbzFor deleting all orders just run the command – php bin/magento webkul:orderDelete -aerLlIh0

    So in this way you can create your own custom commands for any action.

    For complete module please find at https://github.com/webkul/magento2-custom-command .

    Searching for an experienced
    Magento 2 Company ?
    Read More
    . . .
    Discuss on Helpdesk

    Leave a Comment

    Your email address will not be published. Required fields are marked*


    Be the first to comment.

    Back to Top