Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
multiple_mixed_products_rollback.php
Go to the documentation of this file.
1 <?php
8 
11 
12 $registry->unregister('isSecureArea');
13 $registry->register('isSecureArea', true);
14 
16 $productRepository = $objectManager->create(\Magento\Catalog\Api\ProductRepositoryInterface::class);
17 
18 foreach (['simple1', 'simple2', 'simple3'] as $sku) {
19  try {
20  $product = $productRepository->get($sku, false, null, true);
22  } catch (\Magento\Framework\Exception\NoSuchEntityException $exception) {
23  //Product already removed
24  }
25 }
26 foreach (['simple_31', 'simple_32', 'configurable', 'simple_41', 'simple_42', 'configurable_12345'] as $sku) {
27  try {
28  $product = $productRepository->get($sku, false, null, true);
29 
30  $stockStatus = $objectManager->create(\Magento\CatalogInventory\Model\Stock\Status::class);
31  $stockStatus->load($product->getEntityId(), 'product_id');
32  $stockStatus->delete();
33 
35  } catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
36  //Product already removed
37  }
38 }
39 
40 require __DIR__ . '/configurable_attribute_rollback.php';
41 
42 $registry->unregister('isSecureArea');
43 $registry->register('isSecureArea', false);
defined('TESTS_BP')||define('TESTS_BP' __DIR__
Definition: _bootstrap.php:60