- Модуль: sale
- Путь к файлу: ~/bitrix/modules/sale/lib/tradingplatform/vk/feed/data/processors/productsdelete.php
- Класс: BitrixSaleTradingPlatformVkFeedDataProcessorsProductsDelete
- Вызов: ProductsDelete::process
public function process($data = NULL, Timer $timer = NULL)
{
$apiHelper = new ApiHelper($this->exportId);
$productsFromVk = $apiHelper->getProductsFromVk($this->vkGroupId);
$productsMapped = VkMap::getMappedProducts($this->exportId);
// remove from mapping products which not exist in VK
$productsMappedToRemove = array();
foreach ($productsMapped as $key => $productMapped)
{
if (!isset($productsFromVk[$productMapped["VK_ID"]]))
{
$productsMappedToRemove[] = array("VALUE_EXTERNAL" => $productMapped["VK_ID"]);
unset($productsMapped[$key]);
}
}
// remove not exists in VK items
if (!empty($productsMappedToRemove))
VkMap::removeProductMapping($productsMappedToRemove, $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.
$productsMapped = array_chunk($productsMapped, VkVk::MAX_EXECUTION_ITEMS); // max 25 items in execute()
foreach ($productsMapped as $chunk)
{
$resDelete = $this->executer->executeMarketProductDelete(array(
"owner_id" => $this->vkGroupId,
"data" => $chunk,
"count" => count($chunk),
));
foreach ($resDelete as $res)
{
if ($res["flag_product_delete_result"])
$productsMappedToRemove[] = array("VALUE_EXTERNAL" => $res["VK_ID"]);
}
// remove success deleted items
if (!empty($productsMappedToRemove))
VkMap::removeProductMapping($productsMappedToRemove, $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;
}