-
Vadim Justus authoredVadim Justus authored
some-fixture_rollback.php 1.31 KiB
<?php
/**
* Copyright (c) 2019 TechDivision GmbH
* All rights reserved
*
* This product includes proprietary software developed at TechDivision GmbH, Germany
* For more information see http://www.techdivision.com/
*
* To obtain a valid license for using this software please contact us at
* license@techdivision.com
*/
declare(strict_types=1);
use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Framework\Registry;
use Magento\Sales\Api\OrderRepositoryInterface;
use Magento\TestFramework\Helper\Bootstrap;
/** @var Registry $registry */
$registry = Bootstrap::getObjectManager()->get(Registry::class);
$registry->unregister('isSecureArea');
$registry->register('isSecureArea', true);
/** @var OrderRepositoryInterface $orderRepository */
$orderRepository = Bootstrap::getObjectManager()->get(OrderRepositoryInterface::class);
/** @var SearchCriteriaBuilder $searchCriteriaBuilder */
$searchCriteriaBuilder = Bootstrap::getObjectManager()->get(SearchCriteriaBuilder::class);
$searchCriteria = $searchCriteriaBuilder->addFilter(
'increment_id',
'METEXAMPLE-%',
'like'
)->create();
$orders = $orderRepository->getList($searchCriteria);
foreach ($orders->getItems() as $order) {
$orderRepository->delete($order);
}
$registry->unregister('isSecureArea');
$registry->register('isSecureArea', false);