Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
order_status_history_for_search.php
Go to the documentation of this file.
1 <?php
10 
11 require 'default_rollback.php';
12 require __DIR__ . '/order.php';
13 
15  [
16  'comment' => 'comment 1',
17  'is_visible_on_front' => 1,
18  'is_customer_notified' => 1,
19  ],
20  [
21  'comment' => 'comment 2',
22  'is_visible_on_front' => 1,
23  'is_customer_notified' => 1,
24  ],
25  [
26  'comment' => 'comment 3',
27  'is_visible_on_front' => 1,
28  'is_customer_notified' => 1,
29  ],
30  [
31  'comment' => 'comment 4',
32  'is_visible_on_front' => 1,
33  'is_customer_notified' => 1,
34  ],
35  [
36  'comment' => 'comment 5',
37  'is_visible_on_front' => 0,
38  'is_customer_notified' => 1,
39  ],
40 ];
41 
43 $historyRepository = Bootstrap::getObjectManager()->get(OrderStatusHistoryRepositoryInterface::class);
44 
45 foreach ($comments as $data) {
47  $comment = Bootstrap::getObjectManager()->create(History::class);
48  $comment->setParentId($order->getId());
49  $comment->setComment($data['comment']);
50  $comment->setIsVisibleOnFront($data['is_visible_on_front']);
51  $comment->setIsCustomerNotified($data['is_customer_notified']);
52  $historyRepository->save($comment);
53 }
defined('TESTS_BP')||define('TESTS_BP' __DIR__
Definition: _bootstrap.php:60
$order
Definition: order.php:55