• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/tradingplatform/vk/feed/feed.php
  • Класс: Bitrix\Sale\TradingPlatform\Vk\Feed\Feed
  • Вызов: Feed::processData
public function processData($exportId = NULL)
{
//		EMPTY data for deleteAll-operations
	if (!$this->sourceDataIterator)
	{
		$this->dataProcessor->process(NULL, self::getTimer());
	}
	
	else
	{
		$vk = Vk\Vk::getInstance();
		$executionItemsLimit = $exportId ? $vk->getExecutionItemsLimit($exportId) : Vk\Vk::MAX_EXECUTION_ITEMS;
		
		$journal = new Vk\Journal($exportId, $this->feedType);
		$logger = new Vk\Logger($exportId);
		$logger->addLog('Feed start', 'Feed type ' . $this->feedType);
		
		$convertedData = array();
		$nextStepItem = NULL;
		$nextStepFlag = false;
		
		foreach ($this->sourceDataIterator as $data)
		{
			$logger->addLog('Item to convert', 'ID: ' . $data["ID"] . ' NAME: ' . $data["NAME"]);
			if ($nextStepFlag)
			{
				$nextStepItem = $data["ID"];
				break;
			}
			
			if ($currData = $this->dataConvertor->convert($data))
			{
				$convertedData += $currData;
			}
			
			if (count($convertedData) >= $executionItemsLimit)
			{
				$nextStepFlag = true;
			}
		}

//			PROCESSING
		if (count($convertedData) > 0)
		{
			$logger->addLog('Items to process', 'Count '.count($convertedData));
			$this->dataProcessor->process($convertedData, self::getTimer());
			$logger->addLog('Finish process items', 'Count '.count($convertedData));
			$journal->addItemsCount(count($convertedData));
//				for running next step
			if ($nextStepItem)
			{
				throw new TimeIsOverException("VK export next step", $nextStepItem);
			}
		}
		
		if (count($convertedData) == 0 && $this->feedType == 'PRODUCTS')
		{
			$logger->addError('EMPTY_SECTION_PRODUCTS');
		}

//			all OK - close journal
		$journal->end();
		
		$vk->log(
			Logger::LOG_LEVEL_ERROR,
			"VK_FEED__FEED_FINISH_OK",
			'FEED_' . $this->feedType,
			"VKontakte export of " . $this->feedType . " for export profile " . $exportId . " was finished successful. "
		);
	}
}