cancel
Showing results for 
Search instead for 
Did you mean: 

How to Add Custom Mass Action in Order Grid - Change status to Complete

How to Add Custom Mass Action in Order Grid - Change status to Complete

Hi, I am trying to implement a new action in the order grid, however I don't know what is the logic that my code must have to work. Below is an image of what I want to do, as well as a fragment of the code I have implemented.

public function execute()
    {
        $request = $this->getRequest();
      
        $orderIds = $request->getPost('selected', []);
        if (empty($orderIds)) {
            $this->getMessageManager()->addErrorMessage(__('No orders found.'));
            return $this->_redirect('sales/order/index');
        }
        //print_r(orderIds) // Selected Order Ids
        $orderCollection = $this->orderCollectionFactory->create();
        $orderCollection->addFieldToFilter('entity_id', ['in' => $orderIds]);
        try {
            
            //Add logic here
            foreach ($orderCollection as $order) {
                
            }
        } catch (\Exception $e) {
            $message = "An unknown error occurred while changing selected orders.";
            $this->getMessageManager()->addErrorMessage(__($message));
        }
        return $this->_redirect('sales/order/index');
    }

 

WhatsApp Image 2022-01-29 at 8.29.53 AM.jpeg