Untitled

mail@pastecode.io avatar
unknown
php
2 years ago
631 B
4
Indexable
Never
<?php

require($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/prolog_before.php');

\Bitrix\Main\Loader::includeModule('catalog');
\Bitrix\Main\Loader::includeModule('iblock');

$skuId = 74;

$sku =
	\Bitrix\Catalog\v2\IoC\ServiceContainer::getRepositoryFacade()
		->loadVariation($skuId)
;
$imageCollection = $sku->getImageCollection();
$images = $imageCollection->getMorePhotos();
foreach ($images as $image)
{
	print_r($image->getFields());
}

$a = CFile::MakeFileArray($_SERVER['DOCUMENT_ROOT'] . '/Penguins.jpg');
print_r($a);
$imageCollection->addValues([
	$a
]);
var_dump($sku->save());