Y
Y
Yuri Voronin2019-01-28 10:00:34
1C-Bitrix
Yuri Voronin, 2019-01-28 10:00:34

How to add an entry to the order history?

Hello.
I need to add my entry to the order change history. Found the OrderHistory
5c4ea511cedfa386043068.png
class . Perhaps this is what I need. There are several functions that work on adding ( addField , addAction , addLog ). I looked at the description of these functions, judging by the input parameters, it seems like addLog is more suitable for me. Tell me, am I digging in the right direction? Tell me the function, if anyone knows.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
ArmBar, 2019-01-28
@ArmBar

\Bitrix\Main\Loader::includeModule('sale');
$historyEntityType = 'ORDER'; //В данном случае для заказа
$historyType = 'ORDER_COMMENTED'; //Нужный тип можно посмотеть в классе \CSaleOrderChangeFormat в $operationTypes
$order = \Bitrix\Sale\Order::load($orderId);
\Bitrix\Sale\OrderHistory::addAction(
      $historyEntityType,
      $order->getId(),
      $historyType,
      $order->getId(),
      $order,
      ['COMMENTS' => 'Новый комментарий']
);
$order->save();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question