Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
order_virtual_products_rollback.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
15 
17 $registry = Bootstrap::getObjectManager()->get(Registry::class);
18 
20 $orderRepository = Bootstrap::getObjectManager()->get(OrderRepositoryInterface::class);
22 $orderManagement = Bootstrap::getObjectManager()->get(OrderManagementInterface::class);
24 $searchCriteriaBuilder = Bootstrap::getObjectManager()->get(SearchCriteriaBuilder::class);
25 
27  ->addFilter('increment_id', 'created_order_for_test')
28  ->create();
29 
30 $registry->unregister('isSecureArea');
31 $registry->register('isSecureArea', true);
32 
34 $order = current($orderRepository->getList($searchCriteria)->getItems());
35 if ($order) {
36  $orderManagement->cancel($order->getEntityId());
37  $orderRepository->delete($order);
38 }
39 
40 $registry->unregister('isSecureArea');
41 $registry->register('isSecureArea', false);