ProductImage::getAction

  1. Bitrix24 API (v. 23.675.0)
  2. catalog
  3. ProductImage
  4. getAction
  • Модуль: catalog
  • Путь к файлу: ~/bitrix/modules/catalog/lib/controller/productimage.php
  • Класс: BitrixCatalogControllerProductImage
  • Вызов: ProductImage::getAction
public function getAction(int $id, int $productId, CRestServer $restServer = null): ?array
{
	$product = $this->getProduct($productId);
	if (!$product)
	{
		$this->addError(new Error('Product was not found'));
		return null;
	}

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

	$r = $this->hasImage($id, $product);
	if (!$r->isSuccess())
	{
		$this->addErrors($r->getErrors());
		return null;
	}

	/** @var BaseImage $image */
	$image = $product->getImageCollection()->findById($id);

	return ['PRODUCT_IMAGE' => $this->prepareFileStructure($image, $restServer)];
}

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