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