Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
quote_with_item_message_rollback.php
Go to the documentation of this file.
1 <?php
8 $registry->unregister('isSecureArea');
9 $registry->register('isSecureArea', true);
11 $quote = $objectManager->create(\Magento\Quote\Model\Quote::class);
12 $quote->load('test_order_item_with_message', 'reserved_order_id');
13 $message = $objectManager->create(\Magento\GiftMessage\Model\Message::class);
14 $product = $objectManager->create(\Magento\Catalog\Model\Product::class);
15 foreach ($quote->getAllItems() as $item) {
16  $message->load($item->getGiftMessageId());
17  $message->delete();
18  $sku = $item->getSku();
19  $product->load($product->getIdBySku($sku));
20  if ($product->getId()) {
21  $product->delete();
22  }
23 };
24 $quote->delete();
25 $registry->unregister('isSecureArea');
26 $registry->register('isSecureArea', false);