• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/tradingplatform/vk/feed/data/sources/product.php
  • Класс: Bitrix\Sale\TradingPlatform\Vk\Feed\Data\Sources\Product
  • Вызов: Product::__construct
public function __construct($exportId, $startPosition)
{
	$this->vk = Vk\Vk::getInstance();
	
	if (!$this->vk->isActive())
		throw new SystemException("Vk is not active!" . __METHOD__);

//		check and set EXPORT ID
	if (!isset($exportId) || $exportId == '')
		throw new ArgumentNullException("EXPORT_ID");
	$this->exportId = $exportId;

//		check and set START POSITION
	$this->setStartPosition($startPosition);
	
	if (!Loader::includeModule('catalog'))
		throw new SystemException("Can't include module \"Catalog\"! " . __METHOD__);

//		get items only from sections, that was checked to export. And get them iblocksIds
	$sectionsList = new Vk\SectionsList($this->exportId);
	$sectionsToExport = $sectionsList->getSectionsToProductExport();
	$logger = new Vk\Logger($this->exportId);
	if(!empty($sectionsToExport))
	{
		$logger->addLog('Sections to export', $sectionsToExport);
	}
	$iblockIds = $sectionsList->getMappedIblocks();
	
//		if not products to export - ERROR
	if (empty($sectionsToExport))
	{
		$logger->addError('EMPTY_SECTIONS_LIST');
	}

//		create FEEDS
	foreach ($iblockIds as $iblockId)
	{
		$exportOfferParams = array(
			"IBLOCK_ID" => $iblockId,
			"PRODUCT_GROUPS" => $sectionsToExport[$iblockId],
			"INCLUDE_SUBSECTION" => false // we have all sections in PRODUCT_GROUPS, subsections is not needed
		);
//			set start position, if exist. Set current feed as start
		if (isset($this->startPosition[$iblockId]))
		{
			$exportOfferParams["START_POSITION"] = $this->startPosition[$iblockId];
			$this->startFeed = count($this->feeds);
		}
		
		$feed = ExportOfferCreator::getOfferObject($exportOfferParams);
		if($this->vk->getAvailableFlag($this->exportId))
			$feed->setOnlyAvailableFlag(true);
		
		$this->feeds[] = $feed;
		unset($feed);
	}
}