- Модуль: sale
- Путь к файлу: ~/bitrix/modules/sale/lib/tradingplatform/vk/feed/data/processors/albumsdelete.php
- Класс: BitrixSaleTradingPlatformVkFeedDataProcessorsAlbumsDelete
- Вызов: AlbumsDelete::process
public function process($data = NULL, Timer $timer = NULL)
{
$apiHelper = new VkApiApiHelper($this->exportId);
$albumsFromVk = $apiHelper->getALbumsFromVk($this->vkGroupId);
$albumsMapped = VkMap::getMappedAlbums($this->exportId);
// remove from mapping albums which not exist in VK
$albumsMappedToRemove = array();
foreach ($albumsMapped as $key => $albumMapped)
{
if (!isset($albumsFromVk[$albumMapped["ALBUM_VK_ID"]]))
{
$albumsMappedToRemove[] = array("VALUE_EXTERNAL" => $albumMapped["ALBUM_VK_ID"]);
unset($albumsMapped[$key]);
}
}
// remove not exists in VK items
if (!empty($albumsMappedToRemove))
VkMap::removeAlbumMapping($albumsMappedToRemove, $this->exportId);
// In delete procedure we not need http file upload.
// It means that we can not limit max items by settings and using max possible count.
$albumsMapped = array_chunk($albumsMapped, VkVk::MAX_EXECUTION_ITEMS); // max 25 items in execute()
foreach ($albumsMapped as $chunk)
{
$resDelete = $this->executer->executeMarketAlbumDelete(array(
"owner_id" => $this->vkGroupId,
"data" => $chunk,
"count" => count($chunk),
));
foreach ($resDelete as $res)
{
if ($res["flag_album_delete_result"])
$albumsMappedToRemove[] = array("VALUE_EXTERNAL" => $res["ALBUM_VK_ID"]);
}
// remove success deleted items
if (!empty($albumsMappedToRemove))
VkMap::removeAlbumMapping($albumsMappedToRemove, $this->exportId);
// abstract start position - only for continue export, not for rewind to position
if ($timer !== NULL && !$timer->check())
throw new TimeIsOverException("Timelimit for export is over", '1');
}
// remove products from cache
$vkExportedData = new VkVkExportedData($this->exportId, 'PRODUCTS');
$vkExportedData->removeData();
return true;
}