Апрель 12, 2019
Теги: Магазин
Работа с историей заказов при помощи класса "\Bitrix\Sale\Internals\OrderChangeTable".
Получение данных истории по заказу с идентификатором 1319:
$result = \Bitrix\Sale\Internals\OrderChangeTable::getList(array(
'order'=>array('DATE_CREATE'=>'DESC','ID'=>'DESC'),
'filter'=>array('ORDER_ID'=>1319)
));
while($historyItem = $result->fetch())
print_r($historyItem);
/*
Результаты будут представлены в таком виде:
Array
(
[ID] => 33138
[ORDER_ID] => 1319
[TYPE] => ORDER_RESERVED
[DATA] => a:1:{s:8:"RESERVED";s:1:"N";}
[DATE_CREATE] => Bitrix\Main\Type\DateTime Object
(
[value:protected] => DateTime Object
(
[date] => 2018-11-14 00:21:34.000000
[timezone_type] => 3
[timezone] => Europe/Moscow
)
)
[DATE_MODIFY] => Bitrix\Main\Type\DateTime Object
(
[value:protected] => DateTime Object
(
[date] => 2018-11-14 00:21:34.000000
[timezone_type] => 3
[timezone] => Europe/Moscow
)
)
[USER_ID] => 0
[ENTITY] => SHIPMENT
[ENTITY_ID] => 2638
)
Array
(
[ID] => 32509
[ORDER_ID] => 1319
[TYPE] => ORDER_STATUS_CHANGED
[DATA] => a:2:{s:9:"STATUS_ID";s:1:"O";s:13:"OLD_STATUS_ID";s:1:"N";}
[DATE_CREATE] => Bitrix\Main\Type\DateTime Object
(
[value:protected] => DateTime Object
(
[date] => 2018-11-10 16:56:45.000000
[timezone_type] => 3
[timezone] => Europe/Moscow
)
)
[DATE_MODIFY] => Bitrix\Main\Type\DateTime Object
(
[value:protected] => DateTime Object
(
[date] => 2018-11-10 16:56:45.000000
[timezone_type] => 3
[timezone] => Europe/Moscow
)
)
[USER_ID] => 13
[ENTITY] => ORDER
[ENTITY_ID] => 1319
)
Array
(
[ID] => 32432
[ORDER_ID] => 1319
[TYPE] => ORDER_ADDED
[DATA] => a:0:{}
[DATE_CREATE] => Bitrix\Main\Type\DateTime Object
(
[value:protected] => DateTime Object
(
[date] => 2018-11-10 02:21:31.000000
[timezone_type] => 3
[timezone] => Europe/Moscow
)
)
[DATE_MODIFY] => Bitrix\Main\Type\DateTime Object
(
[value:protected] => DateTime Object
(
[date] => 2018-11-10 02:21:31.000000
[timezone_type] => 3
[timezone] => Europe/Moscow
)
)
[USER_ID] => 1
[ENTITY] => ORDER
[ENTITY_ID] => 1319
)
Array
(
[ID] => 32431
[ORDER_ID] => 1319
[TYPE] => SHIPMENT_ITEM_BASKET_ADDED
[DATA] => a:3:{s:8:"QUANTITY";d:1;s:10:"PRODUCT_ID";s:5:"18651";s:4:"NAME";s:19:"UNITOKEN CL 1280-20";}
[DATE_CREATE] => Bitrix\Main\Type\DateTime Object
(
[value:protected] => DateTime Object
(
[date] => 2018-11-10 02:21:31.000000
[timezone_type] => 3
[timezone] => Europe/Moscow
)
)
[DATE_MODIFY] => Bitrix\Main\Type\DateTime Object
(
[value:protected] => DateTime Object
(
[date] => 2018-11-10 02:21:31.000000
[timezone_type] => 3
[timezone] => Europe/Moscow
)
)
[USER_ID] => 1
[ENTITY] => SHIPMENT
[ENTITY_ID] => 2638
)
Array
(
[ID] => 32430
[ORDER_ID] => 1319
[TYPE] => SHIPMENT_ADDED
[DATA] => a:1:{s:13:"DELIVERY_NAME";s:72:"Самовывоз из бесплатного пункта выдачи";}
[DATE_CREATE] => Bitrix\Main\Type\DateTime Object
(
[value:protected] => DateTime Object
(
[date] => 2018-11-10 02:21:31.000000
[timezone_type] => 3
[timezone] => Europe/Moscow
)
)
[DATE_MODIFY] => Bitrix\Main\Type\DateTime Object
(
[value:protected] => DateTime Object
(
[date] => 2018-11-10 02:21:31.000000
[timezone_type] => 3
[timezone] => Europe/Moscow
)
)
[USER_ID] => 1
[ENTITY] => SHIPMENT
[ENTITY_ID] => 2638
)
Array
(
[ID] => 32429
[ORDER_ID] => 1319
[TYPE] => PAYMENT_ADDED
[DATA] => a:2:{s:15:"PAY_SYSTEM_NAME";s:31:"Наличные курьеру";s:3:"SUM";d:500;}
[DATE_CREATE] => Bitrix\Main\Type\DateTime Object
(
[value:protected] => DateTime Object
(
[date] => 2018-11-10 02:21:31.000000
[timezone_type] => 3
[timezone] => Europe/Moscow
)
)
[DATE_MODIFY] => Bitrix\Main\Type\DateTime Object
(
[value:protected] => DateTime Object
(
[date] => 2018-11-10 02:21:31.000000
[timezone_type] => 3
[timezone] => Europe/Moscow
)
)
[USER_ID] => 1
[ENTITY] => PAYMENT
[ENTITY_ID] => 1322
)
*/
Если нужно получить читаемый результат, на 12.04.2019 можно воспользоваться устаревшей функцией "CSaleOrderChange::GetRecordDescription":