Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
quote_with_shipping_method_and_items_categories_rollback.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
10 $registry = $objectManager->get(\Magento\Framework\Registry::class);
11 
12 $registry->unregister('isSecureArea');
13 $registry->register('isSecureArea', true);
14 
15 $productSkuList = ['simple_cat_3', 'simple_cat_4'];
16 foreach ($productSkuList as $sku) {
17  try {
19  ->get(\Magento\Catalog\Api\ProductRepositoryInterface::class);
20  $product = $productRepository->get($sku, true);
21  if ($product->getId()) {
23  }
24  } catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
25  //Product already removed
26  }
27 }
28 
29 //Remove categories
31 $collection = $objectManager->create(\Magento\Catalog\Model\ResourceModel\Category\Collection::class);
33  ->addAttributeToFilter('level', 2)
34  ->load()
35  ->delete();
36 
37 $quote = $objectManager->create(\Magento\Quote\Model\Quote::class);
38 $quote->load('test_order_1', 'reserved_order_id')->delete();
39 
41 $quoteIdMask = $objectManager->create(\Magento\Quote\Model\QuoteIdMask::class);
42 $quoteIdMask->delete($quote->getId());
43 
44 require __DIR__ . '/../../Checkout/_files/quote_with_address_rollback.php';
45 
46 $registry->unregister('isSecureArea');
47 $registry->register('isSecureArea', false);
defined('TESTS_BP')||define('TESTS_BP' __DIR__
Definition: _bootstrap.php:60