• Модуль: catalog
  • Путь к файлу: ~/bitrix/modules/catalog/lib/document/action/price/updateproductpricesaction.php
  • Класс: BitrixCatalogDocumentActionPriceUpdateProductPricesAction
  • Вызов: UpdateProductPricesAction::execute
public function execute(): Result
{
	$result = new Result();

	if (isset($this->purchasePrice))
	{
		$saveResult = Product::update($this->productId, [
			'PURCHASING_PRICE' => $this->purchasePrice ?: null, // if price is 0.0 - clear value
			'PURCHASING_CURRENCY' => $this->purchasePriceCurrency ?? $this->getDefaultCurrency(),
		]);
		if (!$saveResult->isSuccess())
		{
			$result->addErrors(
				$saveResult->getErrors()
			);
		}
	}

	if (isset($this->basePrice))
	{
		$basePriceRowId = $this->getBasePriceRowId();
		if ($basePriceRowId)
		{
			$saveResult = Price::update($basePriceRowId, [
				'PRICE' => $this->basePrice,
				'CURRENCY' => $this->basePriceCurrency,
			]);
		}
		else
		{
			$saveResult = Price::add([
				'PRODUCT_ID' => $this->productId,
				'CATALOG_GROUP_ID' => $this->getBasePriceGroupId(),
				'PRICE' => $this->basePrice,
				'CURRENCY' => $this->basePriceCurrency ?? $this->getDefaultCurrency(),
			]);
		}

		if (!$saveResult->isSuccess())
		{
			$result->addErrors(
				$saveResult->getErrors()
			);
		}
	}

	return $result;
}