Add More Mass action in Order grid in magento2Magento 2 : Add New Grid Mass Action based on conditionAdd mass action in order grid to exportAdding new custom mass order status actionPrint order attachment in magento order mass actionMass action in Sales order gridMass Action in Order GridMagento2: Dynamic Mass Action in Sales GridMagento 2 : Add New Grid Mass Action based on conditionMagento 2 add conditional mass action in sales order gridHide Custom Grid Mass Action for non administrator userMagento2 Mass Action to Sales Order Grid

Telephone number in spoken words

Should I email my professor about a recommendation letter if he has offered me a job?

How to "add" units to results of pgfmathsetmacro?

Are employers legally allowed to pay employees in goods and services equal to or greater than the minimum wage?

Modeling the uncertainty of the input parameters

Scam? Phone call from "Department of Social Security" asking me to call back

Help, I cannot decide when to start the story

Symbol: Put a smile symbol under a plus

Why are Tucker and Malcolm not dead?

Why aren’t there water shutoff valves for each room?

How can God warn people of the upcoming rapture without disrupting society?

How is являться different from есть and быть

How to Check all AD userers for "blank" password?

The cat ate your input again!

What are those bumps on top of the Antonov-225?

How can I see if the data in a SQL Server table is page-compressed?

Lípínguapua dopo Pêpê

Beginner in need of a simple explanation of the difference between order of evaluation and precedence/associativity

A torrent of foreign terms

What is a "soap"?

Website error: "Walmart can’t use this browser"

What is the status of this patent?

Do Reform Jews believe in a theistic God?

Did Pope Urban II issue the papal bull "terra nullius" in 1095?



Add More Mass action in Order grid in magento2


Magento 2 : Add New Grid Mass Action based on conditionAdd mass action in order grid to exportAdding new custom mass order status actionPrint order attachment in magento order mass actionMass action in Sales order gridMass Action in Order GridMagento2: Dynamic Mass Action in Sales GridMagento 2 : Add New Grid Mass Action based on conditionMagento 2 add conditional mass action in sales order gridHide Custom Grid Mass Action for non administrator userMagento2 Mass Action to Sales Order Grid






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








7















I want to create delete order functionality in magento2, but i am not able to add mass action in order grid. please help me how to create delete order functionality in magento2. Please help me if any one have idea.










share|improve this question
































    7















    I want to create delete order functionality in magento2, but i am not able to add mass action in order grid. please help me how to create delete order functionality in magento2. Please help me if any one have idea.










    share|improve this question




























      7












      7








      7


      4






      I want to create delete order functionality in magento2, but i am not able to add mass action in order grid. please help me how to create delete order functionality in magento2. Please help me if any one have idea.










      share|improve this question
















      I want to create delete order functionality in magento2, but i am not able to add mass action in order grid. please help me how to create delete order functionality in magento2. Please help me if any one have idea.







      sales-order magento2 order-grid magento2-dev-beta






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Aug 28 '15 at 10:16









      Ash Smith

      4564 silver badges13 bronze badges




      4564 silver badges13 bronze badges










      asked Aug 17 '15 at 6:32









      Bhaskar ChoubisaBhaskar Choubisa

      3042 silver badges5 bronze badges




      3042 silver badges5 bronze badges























          3 Answers
          3






          active

          oldest

          votes


















          11














          Within your module you will want to create the following file: view/adminhtml/ui_component/sales_order_grid.xml



          With the following:



           <?xml version="1.0" encoding="UTF-8"?>
          <listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Ui/etc/ui_configuration.xsd">
          <container name="listing_top">
          <massaction name="listing_massaction">
          <argument name="data" xsi:type="array">
          <item name="config" xsi:type="array">
          <item name="actions" xsi:type="array">
          <item name="delete" xsi:type="array">
          <item name="type" xsi:type="string">delete</item>
          <item name="label" xsi:type="string" translate="true">Delete</item>
          <item name="url" xsi:type="string">sales/order/massDelete</item>
          </item>
          </item>
          </item>
          </argument>
          </massaction>
          </container>
          </listing>


          Customise the URL path in <item name="url" ..>sales/order/massDelete</item> to your needs.



          Take a look at MagentoSalesControllerAdminhtmlOrderMassCancel.php for an example of how implement your controller!






          share|improve this answer



























          • Hello, I am ablew to add the new mass action but my controller not working when i add in our module , if i put into "Magento/Sales/Controller/Adminhtml/Order" then its working but when i add in our module then its not working . please help me how to add massaction function in our controller?

            – Bhaskar Choubisa
            Sep 15 '15 at 10:11











          • Do you have a etc/adminhtml/routes.xml file within your module? You can use a post I've written covering adminhtml as a reference: ashsmith.io/magento2/module-from-scratch-part-5-adminhtml

            – Ash Smith
            Sep 15 '15 at 14:13











          • Hello Ash, how we can add dynamic mass action using above code

            – Manoj Chowrasiya
            Jun 7 '16 at 17:20


















          10














          You need to define router for adminhtml in order to get it work with your custom module. You can define the same at
          appcodeyour_packageyour_moduleetcadminhtmlroutes.xml as like below:



           <?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="orderdelete" frontName="orderdelete">
          <module name="Krish_OrderDelete" />
          </route>
          </router>
          </config>


          You can define your own frontName for admin route. Now in your ui xml file, available at viewadminhtmlui_component under custom mass action search the item name="url" and set path like "orderdelete/order/massDelete"



          It should work if you will implement it correctly.



          Please refer below module which I developed to add new MassDelete action in sales order grid (All the below files should be in your custom module i.e. package_module).



          1. etcmodule.xml

          <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
          <module name="Krish_OrderDelete" setup_version="1.0.0">
          <sequence>
          <module name="Magento_Sales"/>
          </sequence>
          </module>
          </config>

          2. etcadminhtmlroutes.xml

          <?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="orderdelete" frontName="orderdelete">
          <module name="Krish_OrderDelete" />
          </route>
          </router>
          </config>

          3. viewadminhtmlui_componentsales_order_grid.xml

          <?xml version="1.0" encoding="UTF-8"?>
          <listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
          <listingToolbar name="listing_top">
          <massaction name="listing_massaction">
          <action name="order_delete">
          <argument name="data" xsi:type="array">
          <item name="config" xsi:type="array">
          <item name="type" xsi:type="string">order_delete</item>
          <item name="label" xsi:type="string" translate="true">Delete</item>
          <item name="url" xsi:type="url" path="orderdelete/order/massDelete"/>
          <item name="confirm" xsi:type="array">
          <item name="title" xsi:type="string" translate="true">Delete Order(s)</item>
          <item name="message" xsi:type="string" translate="true">Are you sure you wan't to delete selected items?</item>
          </item>
          </item>
          </argument>
          </action>
          </massaction>
          </listingToolbar>
          </listing>

          **Note: If you will define your action under tag <listingToolbar>, than new mass action will be added as child mass action.**

          4. ControllerAdminhtmlOrderMassDelete.php

          <?php

          namespace KrishOrderDeleteControllerAdminhtmlOrder;

          use MagentoFrameworkModelResourceModelDbCollectionAbstractCollection;
          use MagentoBackendAppActionContext;
          use MagentoUiComponentMassActionFilter;
          use MagentoSalesModelResourceModelOrderCollectionFactory;
          use MagentoSalesApiOrderManagementInterface;

          /**
          * Class MassDelete
          */
          class MassDelete extends MagentoSalesControllerAdminhtmlOrderAbstractMassAction

          /**
          * @var OrderManagementInterface
          */
          protected $orderManagement;

          /**
          * @param Context $context
          * @param Filter $filter
          * @param CollectionFactory $collectionFactory
          * @param OrderManagementInterface $orderManagement
          */
          public function __construct(
          Context $context,
          Filter $filter,
          CollectionFactory $collectionFactory,
          OrderManagementInterface $orderManagement
          )
          parent::__construct($context, $filter);
          $this->collectionFactory = $collectionFactory;
          $this->orderManagement = $orderManagement;


          /**
          * Hold selected orders
          *
          * @param AbstractCollection $collection
          * @return MagentoBackendModelViewResultRedirect
          */
          protected function massAction(AbstractCollection $collection)

          $countDeleteOrder = 0;
          $model = $this->_objectManager->create('MagentoSalesModelOrder');
          foreach ($collection->getItems() as $order)
          if (!$order->getEntityId())
          continue;

          $loadedOrder = $model->load($order->getEntityId());
          $loadedOrder->delete();
          $countDeleteOrder++;

          $countNonDeleteOrder = $collection->count() - $countDeleteOrder;

          if ($countNonDeleteOrder && $countDeleteOrder)
          $this->messageManager->addError(__('%1 order(s) were not deleted.', $countNonDeleteOrder));
          elseif ($countNonDeleteOrder)
          $this->messageManager->addError(__('No order(s) were deleted.'));


          if ($countDeleteOrder)
          $this->messageManager->addSuccess(__('You have deleted %1 order(s).', $countDeleteOrder));


          $resultRedirect = $this->resultRedirectFactory->create();
          $resultRedirect->setPath($this->getComponentRefererUrl());
          return $resultRedirect;



          5. composer.json


          "name": "krish/magento2-order-delete",
          "description": "extension for deleting orders in magento 2",
          "type": "magento2-module",
          "version": "1.0.0",
          "license": [
          "OSL-3.0",
          "AFL-3.0"
          ],
          "require": ~5.6.0,
          "extra":
          "map": [
          [
          "*",
          "Krish/OrderDelete"
          ]
          ]




          6. registration.php

          <?php

          MagentoFrameworkComponentComponentRegistrar::register(
          MagentoFrameworkComponentComponentRegistrar::MODULE,
          'Krish_OrderDelete',
          __DIR__
          );





          share|improve this answer



























          • Hmm Good Answer

            – Murtuza Zabuawala
            Aug 23 '16 at 12:18


















          0














          Not "container" but "listingToolbar" in XML file, and everything works.






          share|improve this answer



























            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "479"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f78861%2fadd-more-mass-action-in-order-grid-in-magento2%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            3 Answers
            3






            active

            oldest

            votes








            3 Answers
            3






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            11














            Within your module you will want to create the following file: view/adminhtml/ui_component/sales_order_grid.xml



            With the following:



             <?xml version="1.0" encoding="UTF-8"?>
            <listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Ui/etc/ui_configuration.xsd">
            <container name="listing_top">
            <massaction name="listing_massaction">
            <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
            <item name="actions" xsi:type="array">
            <item name="delete" xsi:type="array">
            <item name="type" xsi:type="string">delete</item>
            <item name="label" xsi:type="string" translate="true">Delete</item>
            <item name="url" xsi:type="string">sales/order/massDelete</item>
            </item>
            </item>
            </item>
            </argument>
            </massaction>
            </container>
            </listing>


            Customise the URL path in <item name="url" ..>sales/order/massDelete</item> to your needs.



            Take a look at MagentoSalesControllerAdminhtmlOrderMassCancel.php for an example of how implement your controller!






            share|improve this answer



























            • Hello, I am ablew to add the new mass action but my controller not working when i add in our module , if i put into "Magento/Sales/Controller/Adminhtml/Order" then its working but when i add in our module then its not working . please help me how to add massaction function in our controller?

              – Bhaskar Choubisa
              Sep 15 '15 at 10:11











            • Do you have a etc/adminhtml/routes.xml file within your module? You can use a post I've written covering adminhtml as a reference: ashsmith.io/magento2/module-from-scratch-part-5-adminhtml

              – Ash Smith
              Sep 15 '15 at 14:13











            • Hello Ash, how we can add dynamic mass action using above code

              – Manoj Chowrasiya
              Jun 7 '16 at 17:20















            11














            Within your module you will want to create the following file: view/adminhtml/ui_component/sales_order_grid.xml



            With the following:



             <?xml version="1.0" encoding="UTF-8"?>
            <listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Ui/etc/ui_configuration.xsd">
            <container name="listing_top">
            <massaction name="listing_massaction">
            <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
            <item name="actions" xsi:type="array">
            <item name="delete" xsi:type="array">
            <item name="type" xsi:type="string">delete</item>
            <item name="label" xsi:type="string" translate="true">Delete</item>
            <item name="url" xsi:type="string">sales/order/massDelete</item>
            </item>
            </item>
            </item>
            </argument>
            </massaction>
            </container>
            </listing>


            Customise the URL path in <item name="url" ..>sales/order/massDelete</item> to your needs.



            Take a look at MagentoSalesControllerAdminhtmlOrderMassCancel.php for an example of how implement your controller!






            share|improve this answer



























            • Hello, I am ablew to add the new mass action but my controller not working when i add in our module , if i put into "Magento/Sales/Controller/Adminhtml/Order" then its working but when i add in our module then its not working . please help me how to add massaction function in our controller?

              – Bhaskar Choubisa
              Sep 15 '15 at 10:11











            • Do you have a etc/adminhtml/routes.xml file within your module? You can use a post I've written covering adminhtml as a reference: ashsmith.io/magento2/module-from-scratch-part-5-adminhtml

              – Ash Smith
              Sep 15 '15 at 14:13











            • Hello Ash, how we can add dynamic mass action using above code

              – Manoj Chowrasiya
              Jun 7 '16 at 17:20













            11












            11








            11







            Within your module you will want to create the following file: view/adminhtml/ui_component/sales_order_grid.xml



            With the following:



             <?xml version="1.0" encoding="UTF-8"?>
            <listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Ui/etc/ui_configuration.xsd">
            <container name="listing_top">
            <massaction name="listing_massaction">
            <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
            <item name="actions" xsi:type="array">
            <item name="delete" xsi:type="array">
            <item name="type" xsi:type="string">delete</item>
            <item name="label" xsi:type="string" translate="true">Delete</item>
            <item name="url" xsi:type="string">sales/order/massDelete</item>
            </item>
            </item>
            </item>
            </argument>
            </massaction>
            </container>
            </listing>


            Customise the URL path in <item name="url" ..>sales/order/massDelete</item> to your needs.



            Take a look at MagentoSalesControllerAdminhtmlOrderMassCancel.php for an example of how implement your controller!






            share|improve this answer















            Within your module you will want to create the following file: view/adminhtml/ui_component/sales_order_grid.xml



            With the following:



             <?xml version="1.0" encoding="UTF-8"?>
            <listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Ui/etc/ui_configuration.xsd">
            <container name="listing_top">
            <massaction name="listing_massaction">
            <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
            <item name="actions" xsi:type="array">
            <item name="delete" xsi:type="array">
            <item name="type" xsi:type="string">delete</item>
            <item name="label" xsi:type="string" translate="true">Delete</item>
            <item name="url" xsi:type="string">sales/order/massDelete</item>
            </item>
            </item>
            </item>
            </argument>
            </massaction>
            </container>
            </listing>


            Customise the URL path in <item name="url" ..>sales/order/massDelete</item> to your needs.



            Take a look at MagentoSalesControllerAdminhtmlOrderMassCancel.php for an example of how implement your controller!







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Aug 2 at 9:21









            Khushbu

            38013 bronze badges




            38013 bronze badges










            answered Aug 19 '15 at 20:49









            Ash SmithAsh Smith

            4564 silver badges13 bronze badges




            4564 silver badges13 bronze badges















            • Hello, I am ablew to add the new mass action but my controller not working when i add in our module , if i put into "Magento/Sales/Controller/Adminhtml/Order" then its working but when i add in our module then its not working . please help me how to add massaction function in our controller?

              – Bhaskar Choubisa
              Sep 15 '15 at 10:11











            • Do you have a etc/adminhtml/routes.xml file within your module? You can use a post I've written covering adminhtml as a reference: ashsmith.io/magento2/module-from-scratch-part-5-adminhtml

              – Ash Smith
              Sep 15 '15 at 14:13











            • Hello Ash, how we can add dynamic mass action using above code

              – Manoj Chowrasiya
              Jun 7 '16 at 17:20

















            • Hello, I am ablew to add the new mass action but my controller not working when i add in our module , if i put into "Magento/Sales/Controller/Adminhtml/Order" then its working but when i add in our module then its not working . please help me how to add massaction function in our controller?

              – Bhaskar Choubisa
              Sep 15 '15 at 10:11











            • Do you have a etc/adminhtml/routes.xml file within your module? You can use a post I've written covering adminhtml as a reference: ashsmith.io/magento2/module-from-scratch-part-5-adminhtml

              – Ash Smith
              Sep 15 '15 at 14:13











            • Hello Ash, how we can add dynamic mass action using above code

              – Manoj Chowrasiya
              Jun 7 '16 at 17:20
















            Hello, I am ablew to add the new mass action but my controller not working when i add in our module , if i put into "Magento/Sales/Controller/Adminhtml/Order" then its working but when i add in our module then its not working . please help me how to add massaction function in our controller?

            – Bhaskar Choubisa
            Sep 15 '15 at 10:11





            Hello, I am ablew to add the new mass action but my controller not working when i add in our module , if i put into "Magento/Sales/Controller/Adminhtml/Order" then its working but when i add in our module then its not working . please help me how to add massaction function in our controller?

            – Bhaskar Choubisa
            Sep 15 '15 at 10:11













            Do you have a etc/adminhtml/routes.xml file within your module? You can use a post I've written covering adminhtml as a reference: ashsmith.io/magento2/module-from-scratch-part-5-adminhtml

            – Ash Smith
            Sep 15 '15 at 14:13





            Do you have a etc/adminhtml/routes.xml file within your module? You can use a post I've written covering adminhtml as a reference: ashsmith.io/magento2/module-from-scratch-part-5-adminhtml

            – Ash Smith
            Sep 15 '15 at 14:13













            Hello Ash, how we can add dynamic mass action using above code

            – Manoj Chowrasiya
            Jun 7 '16 at 17:20





            Hello Ash, how we can add dynamic mass action using above code

            – Manoj Chowrasiya
            Jun 7 '16 at 17:20













            10














            You need to define router for adminhtml in order to get it work with your custom module. You can define the same at
            appcodeyour_packageyour_moduleetcadminhtmlroutes.xml as like below:



             <?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="orderdelete" frontName="orderdelete">
            <module name="Krish_OrderDelete" />
            </route>
            </router>
            </config>


            You can define your own frontName for admin route. Now in your ui xml file, available at viewadminhtmlui_component under custom mass action search the item name="url" and set path like "orderdelete/order/massDelete"



            It should work if you will implement it correctly.



            Please refer below module which I developed to add new MassDelete action in sales order grid (All the below files should be in your custom module i.e. package_module).



            1. etcmodule.xml

            <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
            <module name="Krish_OrderDelete" setup_version="1.0.0">
            <sequence>
            <module name="Magento_Sales"/>
            </sequence>
            </module>
            </config>

            2. etcadminhtmlroutes.xml

            <?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="orderdelete" frontName="orderdelete">
            <module name="Krish_OrderDelete" />
            </route>
            </router>
            </config>

            3. viewadminhtmlui_componentsales_order_grid.xml

            <?xml version="1.0" encoding="UTF-8"?>
            <listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
            <listingToolbar name="listing_top">
            <massaction name="listing_massaction">
            <action name="order_delete">
            <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
            <item name="type" xsi:type="string">order_delete</item>
            <item name="label" xsi:type="string" translate="true">Delete</item>
            <item name="url" xsi:type="url" path="orderdelete/order/massDelete"/>
            <item name="confirm" xsi:type="array">
            <item name="title" xsi:type="string" translate="true">Delete Order(s)</item>
            <item name="message" xsi:type="string" translate="true">Are you sure you wan't to delete selected items?</item>
            </item>
            </item>
            </argument>
            </action>
            </massaction>
            </listingToolbar>
            </listing>

            **Note: If you will define your action under tag <listingToolbar>, than new mass action will be added as child mass action.**

            4. ControllerAdminhtmlOrderMassDelete.php

            <?php

            namespace KrishOrderDeleteControllerAdminhtmlOrder;

            use MagentoFrameworkModelResourceModelDbCollectionAbstractCollection;
            use MagentoBackendAppActionContext;
            use MagentoUiComponentMassActionFilter;
            use MagentoSalesModelResourceModelOrderCollectionFactory;
            use MagentoSalesApiOrderManagementInterface;

            /**
            * Class MassDelete
            */
            class MassDelete extends MagentoSalesControllerAdminhtmlOrderAbstractMassAction

            /**
            * @var OrderManagementInterface
            */
            protected $orderManagement;

            /**
            * @param Context $context
            * @param Filter $filter
            * @param CollectionFactory $collectionFactory
            * @param OrderManagementInterface $orderManagement
            */
            public function __construct(
            Context $context,
            Filter $filter,
            CollectionFactory $collectionFactory,
            OrderManagementInterface $orderManagement
            )
            parent::__construct($context, $filter);
            $this->collectionFactory = $collectionFactory;
            $this->orderManagement = $orderManagement;


            /**
            * Hold selected orders
            *
            * @param AbstractCollection $collection
            * @return MagentoBackendModelViewResultRedirect
            */
            protected function massAction(AbstractCollection $collection)

            $countDeleteOrder = 0;
            $model = $this->_objectManager->create('MagentoSalesModelOrder');
            foreach ($collection->getItems() as $order)
            if (!$order->getEntityId())
            continue;

            $loadedOrder = $model->load($order->getEntityId());
            $loadedOrder->delete();
            $countDeleteOrder++;

            $countNonDeleteOrder = $collection->count() - $countDeleteOrder;

            if ($countNonDeleteOrder && $countDeleteOrder)
            $this->messageManager->addError(__('%1 order(s) were not deleted.', $countNonDeleteOrder));
            elseif ($countNonDeleteOrder)
            $this->messageManager->addError(__('No order(s) were deleted.'));


            if ($countDeleteOrder)
            $this->messageManager->addSuccess(__('You have deleted %1 order(s).', $countDeleteOrder));


            $resultRedirect = $this->resultRedirectFactory->create();
            $resultRedirect->setPath($this->getComponentRefererUrl());
            return $resultRedirect;



            5. composer.json


            "name": "krish/magento2-order-delete",
            "description": "extension for deleting orders in magento 2",
            "type": "magento2-module",
            "version": "1.0.0",
            "license": [
            "OSL-3.0",
            "AFL-3.0"
            ],
            "require": ~5.6.0,
            "extra":
            "map": [
            [
            "*",
            "Krish/OrderDelete"
            ]
            ]




            6. registration.php

            <?php

            MagentoFrameworkComponentComponentRegistrar::register(
            MagentoFrameworkComponentComponentRegistrar::MODULE,
            'Krish_OrderDelete',
            __DIR__
            );





            share|improve this answer



























            • Hmm Good Answer

              – Murtuza Zabuawala
              Aug 23 '16 at 12:18















            10














            You need to define router for adminhtml in order to get it work with your custom module. You can define the same at
            appcodeyour_packageyour_moduleetcadminhtmlroutes.xml as like below:



             <?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="orderdelete" frontName="orderdelete">
            <module name="Krish_OrderDelete" />
            </route>
            </router>
            </config>


            You can define your own frontName for admin route. Now in your ui xml file, available at viewadminhtmlui_component under custom mass action search the item name="url" and set path like "orderdelete/order/massDelete"



            It should work if you will implement it correctly.



            Please refer below module which I developed to add new MassDelete action in sales order grid (All the below files should be in your custom module i.e. package_module).



            1. etcmodule.xml

            <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
            <module name="Krish_OrderDelete" setup_version="1.0.0">
            <sequence>
            <module name="Magento_Sales"/>
            </sequence>
            </module>
            </config>

            2. etcadminhtmlroutes.xml

            <?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="orderdelete" frontName="orderdelete">
            <module name="Krish_OrderDelete" />
            </route>
            </router>
            </config>

            3. viewadminhtmlui_componentsales_order_grid.xml

            <?xml version="1.0" encoding="UTF-8"?>
            <listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
            <listingToolbar name="listing_top">
            <massaction name="listing_massaction">
            <action name="order_delete">
            <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
            <item name="type" xsi:type="string">order_delete</item>
            <item name="label" xsi:type="string" translate="true">Delete</item>
            <item name="url" xsi:type="url" path="orderdelete/order/massDelete"/>
            <item name="confirm" xsi:type="array">
            <item name="title" xsi:type="string" translate="true">Delete Order(s)</item>
            <item name="message" xsi:type="string" translate="true">Are you sure you wan't to delete selected items?</item>
            </item>
            </item>
            </argument>
            </action>
            </massaction>
            </listingToolbar>
            </listing>

            **Note: If you will define your action under tag <listingToolbar>, than new mass action will be added as child mass action.**

            4. ControllerAdminhtmlOrderMassDelete.php

            <?php

            namespace KrishOrderDeleteControllerAdminhtmlOrder;

            use MagentoFrameworkModelResourceModelDbCollectionAbstractCollection;
            use MagentoBackendAppActionContext;
            use MagentoUiComponentMassActionFilter;
            use MagentoSalesModelResourceModelOrderCollectionFactory;
            use MagentoSalesApiOrderManagementInterface;

            /**
            * Class MassDelete
            */
            class MassDelete extends MagentoSalesControllerAdminhtmlOrderAbstractMassAction

            /**
            * @var OrderManagementInterface
            */
            protected $orderManagement;

            /**
            * @param Context $context
            * @param Filter $filter
            * @param CollectionFactory $collectionFactory
            * @param OrderManagementInterface $orderManagement
            */
            public function __construct(
            Context $context,
            Filter $filter,
            CollectionFactory $collectionFactory,
            OrderManagementInterface $orderManagement
            )
            parent::__construct($context, $filter);
            $this->collectionFactory = $collectionFactory;
            $this->orderManagement = $orderManagement;


            /**
            * Hold selected orders
            *
            * @param AbstractCollection $collection
            * @return MagentoBackendModelViewResultRedirect
            */
            protected function massAction(AbstractCollection $collection)

            $countDeleteOrder = 0;
            $model = $this->_objectManager->create('MagentoSalesModelOrder');
            foreach ($collection->getItems() as $order)
            if (!$order->getEntityId())
            continue;

            $loadedOrder = $model->load($order->getEntityId());
            $loadedOrder->delete();
            $countDeleteOrder++;

            $countNonDeleteOrder = $collection->count() - $countDeleteOrder;

            if ($countNonDeleteOrder && $countDeleteOrder)
            $this->messageManager->addError(__('%1 order(s) were not deleted.', $countNonDeleteOrder));
            elseif ($countNonDeleteOrder)
            $this->messageManager->addError(__('No order(s) were deleted.'));


            if ($countDeleteOrder)
            $this->messageManager->addSuccess(__('You have deleted %1 order(s).', $countDeleteOrder));


            $resultRedirect = $this->resultRedirectFactory->create();
            $resultRedirect->setPath($this->getComponentRefererUrl());
            return $resultRedirect;



            5. composer.json


            "name": "krish/magento2-order-delete",
            "description": "extension for deleting orders in magento 2",
            "type": "magento2-module",
            "version": "1.0.0",
            "license": [
            "OSL-3.0",
            "AFL-3.0"
            ],
            "require": ~5.6.0,
            "extra":
            "map": [
            [
            "*",
            "Krish/OrderDelete"
            ]
            ]




            6. registration.php

            <?php

            MagentoFrameworkComponentComponentRegistrar::register(
            MagentoFrameworkComponentComponentRegistrar::MODULE,
            'Krish_OrderDelete',
            __DIR__
            );





            share|improve this answer



























            • Hmm Good Answer

              – Murtuza Zabuawala
              Aug 23 '16 at 12:18













            10












            10








            10







            You need to define router for adminhtml in order to get it work with your custom module. You can define the same at
            appcodeyour_packageyour_moduleetcadminhtmlroutes.xml as like below:



             <?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="orderdelete" frontName="orderdelete">
            <module name="Krish_OrderDelete" />
            </route>
            </router>
            </config>


            You can define your own frontName for admin route. Now in your ui xml file, available at viewadminhtmlui_component under custom mass action search the item name="url" and set path like "orderdelete/order/massDelete"



            It should work if you will implement it correctly.



            Please refer below module which I developed to add new MassDelete action in sales order grid (All the below files should be in your custom module i.e. package_module).



            1. etcmodule.xml

            <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
            <module name="Krish_OrderDelete" setup_version="1.0.0">
            <sequence>
            <module name="Magento_Sales"/>
            </sequence>
            </module>
            </config>

            2. etcadminhtmlroutes.xml

            <?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="orderdelete" frontName="orderdelete">
            <module name="Krish_OrderDelete" />
            </route>
            </router>
            </config>

            3. viewadminhtmlui_componentsales_order_grid.xml

            <?xml version="1.0" encoding="UTF-8"?>
            <listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
            <listingToolbar name="listing_top">
            <massaction name="listing_massaction">
            <action name="order_delete">
            <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
            <item name="type" xsi:type="string">order_delete</item>
            <item name="label" xsi:type="string" translate="true">Delete</item>
            <item name="url" xsi:type="url" path="orderdelete/order/massDelete"/>
            <item name="confirm" xsi:type="array">
            <item name="title" xsi:type="string" translate="true">Delete Order(s)</item>
            <item name="message" xsi:type="string" translate="true">Are you sure you wan't to delete selected items?</item>
            </item>
            </item>
            </argument>
            </action>
            </massaction>
            </listingToolbar>
            </listing>

            **Note: If you will define your action under tag <listingToolbar>, than new mass action will be added as child mass action.**

            4. ControllerAdminhtmlOrderMassDelete.php

            <?php

            namespace KrishOrderDeleteControllerAdminhtmlOrder;

            use MagentoFrameworkModelResourceModelDbCollectionAbstractCollection;
            use MagentoBackendAppActionContext;
            use MagentoUiComponentMassActionFilter;
            use MagentoSalesModelResourceModelOrderCollectionFactory;
            use MagentoSalesApiOrderManagementInterface;

            /**
            * Class MassDelete
            */
            class MassDelete extends MagentoSalesControllerAdminhtmlOrderAbstractMassAction

            /**
            * @var OrderManagementInterface
            */
            protected $orderManagement;

            /**
            * @param Context $context
            * @param Filter $filter
            * @param CollectionFactory $collectionFactory
            * @param OrderManagementInterface $orderManagement
            */
            public function __construct(
            Context $context,
            Filter $filter,
            CollectionFactory $collectionFactory,
            OrderManagementInterface $orderManagement
            )
            parent::__construct($context, $filter);
            $this->collectionFactory = $collectionFactory;
            $this->orderManagement = $orderManagement;


            /**
            * Hold selected orders
            *
            * @param AbstractCollection $collection
            * @return MagentoBackendModelViewResultRedirect
            */
            protected function massAction(AbstractCollection $collection)

            $countDeleteOrder = 0;
            $model = $this->_objectManager->create('MagentoSalesModelOrder');
            foreach ($collection->getItems() as $order)
            if (!$order->getEntityId())
            continue;

            $loadedOrder = $model->load($order->getEntityId());
            $loadedOrder->delete();
            $countDeleteOrder++;

            $countNonDeleteOrder = $collection->count() - $countDeleteOrder;

            if ($countNonDeleteOrder && $countDeleteOrder)
            $this->messageManager->addError(__('%1 order(s) were not deleted.', $countNonDeleteOrder));
            elseif ($countNonDeleteOrder)
            $this->messageManager->addError(__('No order(s) were deleted.'));


            if ($countDeleteOrder)
            $this->messageManager->addSuccess(__('You have deleted %1 order(s).', $countDeleteOrder));


            $resultRedirect = $this->resultRedirectFactory->create();
            $resultRedirect->setPath($this->getComponentRefererUrl());
            return $resultRedirect;



            5. composer.json


            "name": "krish/magento2-order-delete",
            "description": "extension for deleting orders in magento 2",
            "type": "magento2-module",
            "version": "1.0.0",
            "license": [
            "OSL-3.0",
            "AFL-3.0"
            ],
            "require": ~5.6.0,
            "extra":
            "map": [
            [
            "*",
            "Krish/OrderDelete"
            ]
            ]




            6. registration.php

            <?php

            MagentoFrameworkComponentComponentRegistrar::register(
            MagentoFrameworkComponentComponentRegistrar::MODULE,
            'Krish_OrderDelete',
            __DIR__
            );





            share|improve this answer















            You need to define router for adminhtml in order to get it work with your custom module. You can define the same at
            appcodeyour_packageyour_moduleetcadminhtmlroutes.xml as like below:



             <?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="orderdelete" frontName="orderdelete">
            <module name="Krish_OrderDelete" />
            </route>
            </router>
            </config>


            You can define your own frontName for admin route. Now in your ui xml file, available at viewadminhtmlui_component under custom mass action search the item name="url" and set path like "orderdelete/order/massDelete"



            It should work if you will implement it correctly.



            Please refer below module which I developed to add new MassDelete action in sales order grid (All the below files should be in your custom module i.e. package_module).



            1. etcmodule.xml

            <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
            <module name="Krish_OrderDelete" setup_version="1.0.0">
            <sequence>
            <module name="Magento_Sales"/>
            </sequence>
            </module>
            </config>

            2. etcadminhtmlroutes.xml

            <?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="orderdelete" frontName="orderdelete">
            <module name="Krish_OrderDelete" />
            </route>
            </router>
            </config>

            3. viewadminhtmlui_componentsales_order_grid.xml

            <?xml version="1.0" encoding="UTF-8"?>
            <listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
            <listingToolbar name="listing_top">
            <massaction name="listing_massaction">
            <action name="order_delete">
            <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
            <item name="type" xsi:type="string">order_delete</item>
            <item name="label" xsi:type="string" translate="true">Delete</item>
            <item name="url" xsi:type="url" path="orderdelete/order/massDelete"/>
            <item name="confirm" xsi:type="array">
            <item name="title" xsi:type="string" translate="true">Delete Order(s)</item>
            <item name="message" xsi:type="string" translate="true">Are you sure you wan't to delete selected items?</item>
            </item>
            </item>
            </argument>
            </action>
            </massaction>
            </listingToolbar>
            </listing>

            **Note: If you will define your action under tag <listingToolbar>, than new mass action will be added as child mass action.**

            4. ControllerAdminhtmlOrderMassDelete.php

            <?php

            namespace KrishOrderDeleteControllerAdminhtmlOrder;

            use MagentoFrameworkModelResourceModelDbCollectionAbstractCollection;
            use MagentoBackendAppActionContext;
            use MagentoUiComponentMassActionFilter;
            use MagentoSalesModelResourceModelOrderCollectionFactory;
            use MagentoSalesApiOrderManagementInterface;

            /**
            * Class MassDelete
            */
            class MassDelete extends MagentoSalesControllerAdminhtmlOrderAbstractMassAction

            /**
            * @var OrderManagementInterface
            */
            protected $orderManagement;

            /**
            * @param Context $context
            * @param Filter $filter
            * @param CollectionFactory $collectionFactory
            * @param OrderManagementInterface $orderManagement
            */
            public function __construct(
            Context $context,
            Filter $filter,
            CollectionFactory $collectionFactory,
            OrderManagementInterface $orderManagement
            )
            parent::__construct($context, $filter);
            $this->collectionFactory = $collectionFactory;
            $this->orderManagement = $orderManagement;


            /**
            * Hold selected orders
            *
            * @param AbstractCollection $collection
            * @return MagentoBackendModelViewResultRedirect
            */
            protected function massAction(AbstractCollection $collection)

            $countDeleteOrder = 0;
            $model = $this->_objectManager->create('MagentoSalesModelOrder');
            foreach ($collection->getItems() as $order)
            if (!$order->getEntityId())
            continue;

            $loadedOrder = $model->load($order->getEntityId());
            $loadedOrder->delete();
            $countDeleteOrder++;

            $countNonDeleteOrder = $collection->count() - $countDeleteOrder;

            if ($countNonDeleteOrder && $countDeleteOrder)
            $this->messageManager->addError(__('%1 order(s) were not deleted.', $countNonDeleteOrder));
            elseif ($countNonDeleteOrder)
            $this->messageManager->addError(__('No order(s) were deleted.'));


            if ($countDeleteOrder)
            $this->messageManager->addSuccess(__('You have deleted %1 order(s).', $countDeleteOrder));


            $resultRedirect = $this->resultRedirectFactory->create();
            $resultRedirect->setPath($this->getComponentRefererUrl());
            return $resultRedirect;



            5. composer.json


            "name": "krish/magento2-order-delete",
            "description": "extension for deleting orders in magento 2",
            "type": "magento2-module",
            "version": "1.0.0",
            "license": [
            "OSL-3.0",
            "AFL-3.0"
            ],
            "require": ~5.6.0,
            "extra":
            "map": [
            [
            "*",
            "Krish/OrderDelete"
            ]
            ]




            6. registration.php

            <?php

            MagentoFrameworkComponentComponentRegistrar::register(
            MagentoFrameworkComponentComponentRegistrar::MODULE,
            'Krish_OrderDelete',
            __DIR__
            );






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Nov 9 '17 at 11:47

























            answered Aug 23 '16 at 11:50









            Himmat PaliwalHimmat Paliwal

            1,2715 silver badges20 bronze badges




            1,2715 silver badges20 bronze badges















            • Hmm Good Answer

              – Murtuza Zabuawala
              Aug 23 '16 at 12:18

















            • Hmm Good Answer

              – Murtuza Zabuawala
              Aug 23 '16 at 12:18
















            Hmm Good Answer

            – Murtuza Zabuawala
            Aug 23 '16 at 12:18





            Hmm Good Answer

            – Murtuza Zabuawala
            Aug 23 '16 at 12:18











            0














            Not "container" but "listingToolbar" in XML file, and everything works.






            share|improve this answer





























              0














              Not "container" but "listingToolbar" in XML file, and everything works.






              share|improve this answer



























                0












                0








                0







                Not "container" but "listingToolbar" in XML file, and everything works.






                share|improve this answer













                Not "container" but "listingToolbar" in XML file, and everything works.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Aug 2 '17 at 9:10









                Mateusz TofilskiMateusz Tofilski

                1




                1






























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Magento Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f78861%2fadd-more-mass-action-in-order-grid-in-magento2%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

                    Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

                    Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form