order_rollback.php 897 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. declare(strict_types=1);
  7. use Magento\Framework\Api\SearchCriteriaBuilder;
  8. use Magento\Sales\Api\OrderRepositoryInterface;
  9. use Magento\TestFramework\ObjectManager;
  10. $objectManager = ObjectManager::getInstance();
  11. /** @var SearchCriteriaBuilder $searchCriteriaBuilder */
  12. $searchCriteriaBuilder = $objectManager->get(SearchCriteriaBuilder::class);
  13. $searchCriteria = $searchCriteriaBuilder->addFilter('increment_id', '100000002')
  14. ->create();
  15. /** @var OrderRepositoryInterface $orderRepository */
  16. $orderRepository = $objectManager->get(OrderRepositoryInterface::class);
  17. $items = $orderRepository->getList($searchCriteria)
  18. ->getItems();
  19. foreach ($items as $item) {
  20. $orderRepository->delete($item);
  21. }
  22. require __DIR__ . '/../../../Magento/Catalog/_files/product_simple_rollback.php';