Price::modifySingleProductPrice

  1. Bitrix24 API (v. 23.675.0)
  2. catalog
  3. Price
  4. modifySingleProductPrice
  • Модуль: catalog
  • Путь к файлу: ~/bitrix/modules/catalog/lib/controller/price.php
  • Класс: BitrixCatalogControllerPrice
  • Вызов: Price::modifySingleProductPrice
private function modifySingleProductPrice(array $fields): ?array
{
	$resultGroupType = GroupTable::getRowById((int)$fields['CATALOG_GROUP_ID']);
	if (!$resultGroupType)
	{
		$this->addError(new Error('Validate price error. Catalog price group is wrong'));

		return null;
	}

	$entityTable = $this->getEntityTable();
	$prices =
		$entityTable::getList(
			[
				'filter' => [
					'=PRODUCT_ID' => $fields['PRODUCT_ID'],
					'=CATALOG_GROUP_ID' => $fields['CATALOG_GROUP_ID'],
				]
			]
		)
		->fetchAll()
	;

	$prices = array_combine(array_column($prices, 'ID'), $prices);
	$prices[$fields['ID']] = $fields;

	$r = $this->modifyValidate($prices);
	if ($r->isSuccess())
	{
		$r = $this->modify([
			'PRODUCT' => [
				'ID' => $fields['PRODUCT_ID'],
				'PRICES' => [$fields]
			]
		]);
	}

	if (!$r->isSuccess())
	{
		$this->addErrors($r->getErrors());
		return null;
	}

	$ids = $r->getData()[0];

	return [
		'PRICE'=>$this->get($ids[0])
	];
}

Добавить комментарий