• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/shipmentitemstore.php
  • Класс: BitrixSaleShipmentItemStore
  • Вызов: ShipmentItemStore::save
public function save()
{
	$result = new Result();

	$this->checkCallingContext();

	if (!$this->isChanged() || $this->getQuantity() === 0)
	{
		return $result;
	}

	$this->callEventOnBeforeItemStoreEntitySaved();

	$id = $this->getId();

	if ($id > 0)
	{
		$r = $this->updateInternal($id, $this->getFields()->getChangedValues());
	}
	else
	{
		/** @var ShipmentItemStoreCollection $itemStoreCollection */
		$itemStoreCollection = $this->getCollection();

		if (!$this->getField("ORDER_DELIVERY_BASKET_ID"))
		{
			$this->setFieldNoDemand('ORDER_DELIVERY_BASKET_ID', $itemStoreCollection->getShipmentItem()->getId());
		}

		if (!$this->getField("BASKET_ID"))
		{
			$this->setFieldNoDemand('BASKET_ID', $itemStoreCollection->getShipmentItem()->getBasketItem()->getId());
		}

		$this->setFieldNoDemand('DATE_CREATE', new MainTypeDateTime());

		$r = $this->addInternal($this->getFields()->getValues());
		if ($r->isSuccess())
		{
			$id = $r->getId();

			$this->setFieldNoDemand('ID', $id);
		}
	}

	if (!$r->isSuccess())
	{
		$this->addErrorMessagesToHistory($r->getErrorMessages());

		$result->addErrors($r->getErrors());

		return $result;
	}

	if ($id > 0)
	{
		$result->setId($id);
	}

	$this->callEventOnItemStoreEntitySaved();

	return $result;
}