src/Flowcode/ShopBundle/Service/ProductOrderService.php
/**
     * Disable old draft orders.
     * @return array
     */
Disable old draft orders.
@return array
Disable old draft orders . @return array
public function clearDrafts()
    {
        $interval = new \DateInterval('P1D');
        $dateTo = new \DateTime();
        $dateTo->sub($interval);
        $orders = $this->productOrderRepository->getDraftsBetween(null, $dateTo);
        $processedCount = 0;
        foreach ($orders as $productOrder) {
            $productOrder->setEnabled(false);
            $processedCount++;
        }
        $this->getEm()->flush();
        return [
            'processed' => $processedCount
        ];
    }
public function clearDrafts ( ) { $ interval = new \ DateInterval ( 'P1D' ) ; $ dateTo = new \ DateTime ( ) ; $ dateTo -> sub ( $ interval ) ; $ orders = $ this -> productOrderRepository -> getDraftsBetween ( null , $ dateTo ) ; $ processedCount = 0 ; foreach ( $ orders as $ productOrder ) { $ productOrder -> setEnabled ( false ) ; $ processedCount ++ ; } $ this -> getEm ( ) -> flush ( ) ; return [ 'processed' => $ processedCount ] ; }
Disable old draft orders.
Disable old draft orders .
/** @var ProductOrder $productOrder */