3

I want to set cron job for order confirm. Below controller code Confirm.php used for confirm order from my fronted custom module. This will Set order status confirm. This is working fine.

<?php 
namespace \<vender>\<module>\Controller\Order;


class Confirm extends \<vender>\<module>\Controller\Order
{
    /**
     * Seller Order Confirm page.
     *
     * @return \Magento\Framework\View\Result\Page
     */
    public function execute()
    {
        $order_id = $this->getRequest()->getParam('order_ids');

        $sellerId = $this->_customerSession->getCustomerId();
        try {
            $trackingcoll = $this->_objectManager->create(
                                '<vender>\<module>\Model\Orders'
                            )
                            ->getCollection()
                            ->addFieldToFilter(
                                'order_id',
                                $order_id
                            )
                            ->addFieldToFilter(
                                'seller_id',
                                $sellerId
                            );

                         foreach ($trackingcoll as $tracking) {
                            $tracking->setSellerOrderConfirm('Confirmed');
                            $tracking->save();
                        }
                    $this->messageManager->addSuccess(
                        __('The order has been Confirmed by Seller.')
                    );

        }catch (\Magento\Framework\Exception\LocalizedException $e) {
                    $this->messageManager->addError($e->getMessage());
                } catch (\Exception $e) {
                    $this->messageManager->addError(
                        __('We can\'t send the email order right now.')
                    );
        }
         return $this->resultRedirectFactory->create()->setPath(
                    '*/*/history', 
                    ['_secure' => $this->getRequest()->isSecure()]
                );


    }
}

Same code used in corn page to check pending order & set order confirm.
My question is as follow.

  1. Can changing status sufficient to make order status confirm or want to do something more?
  2. Is there any performance issues if I run cron for every two hours?
  3. Is there any harm to set auto email sending for order confirm?

Thanks in Advance.

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.