• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/shipmentitem.php
  • Класс: BitrixSaleShipmentItem
  • Вызов: ShipmentItem::addChangesToHistory
protected function addChangesToHistory($name, $oldValue = null, $value = null)
{
	if ($this->getId() > 0)
	{
		/** @var ShipmentItemCollection $shipmentItemCollection */
		if (!$shipmentItemCollection = $this->getCollection())
		{
			throw new MainObjectNotFoundException('Entity "ShipmentItemCollection" not found');
		}

		/** @var Shipment $shipment */
		if (!$shipment = $shipmentItemCollection->getShipment())
		{
			throw new MainObjectNotFoundException('Entity "Shipment" not found');
		}

		if ($shipment->isSystem())
			return;

		/** @var ShipmentCollection $shipmentCollection */
		if (!$shipmentCollection = $shipment->getCollection())
		{
			throw new MainObjectNotFoundException('Entity "ShipmentCollection" not found');
		}

		$historyFields = [];

		/** @var BasketItem $basketItem */
		if ($basketItem = $this->getBasketItem())
		{
			$historyFields = [
				'NAME' => $basketItem->getField('NAME'),
				'PRODUCT_ID' => $basketItem->getField('PRODUCT_ID'),
			];
		}

		/** @var Order $order */
		if (($order = $shipmentCollection->getOrder()) && $order->getId() > 0)
		{
			$registry = Registry::getInstance(static::getRegistryType());

			/** @var OrderHistory $orderHistory */
			$orderHistory = $registry->getOrderHistoryClassName();
			$orderHistory::addField(
				'SHIPMENT_ITEM',
				$order->getId(),
				$name,
				$oldValue,
				$value,
				$this->getId(),
				$this,
				$historyFields
			);
		}


	}
}