If customer order status is pending and more than 30 days, how to change customer group to wholesale in crons?

crons should run at every one minute.

This is my code

public function execute()
     $today          = date("Y-m-d h:i:s");
     $to             = strtotime('-02 min', strtotime($today));
     $to             = date('Y-m-d h:i:s', $to);

    $filterGroupDate      = $this->filterGroup;
    $filterGroupStatus    = clone($filterGroupDate);

     $filterDate      = $this->filterBuilder
    $filterStatus    = $this->filterBuilder


    $searchCriteria = $this->searchCriteriaBuilder->setFilterGroups(
    $searchResults  = $this->orderRepository->getList($searchCriteria->create());


    /** @var Order $order */
    foreach ($searchResults->getItems() as $order) {
         $customer = $order->getCustomer();
         $customer->setData('customer_group_id', $selectedgroup)->save();



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.