Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
product_simple_xss_rollback.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
10 
12 $registry = $objectManager->get(\Magento\Framework\Registry::class);
13 
14 $registry->unregister('isSecureArea');
15 $registry->register('isSecureArea', true);
16 
17 try {
19  ->get(\Magento\Catalog\Api\ProductRepositoryInterface::class);
20  $product = $productRepository->get('product-with-xss', true);
21  if ($product->getId()) {
23  }
24 } catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
25  //Product already removed
26 }
27 
28 $registry->unregister('isSecureArea');
29 $registry->register('isSecureArea', false);