Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
productsdeleteall.php
1<?php
2
4
8
14{
21 public function process($data = NULL, Timer $timer = NULL)
22 {
23 $apiHelper = new Vk\Api\ApiHelper($this->exportId);
24 $productsFromVk = $apiHelper->getProductsFromVk($this->vkGroupId);
25 $productsMapped = Vk\Map::getMappedProducts($this->exportId);
26
27// delete ALL from mapping
28 $productsMappedToRemove = array();
29 foreach ($productsMapped as $productMapped)
30 $productsMappedToRemove[] = array("VALUE_EXTERNAL" => $productMapped["VK_ID"]);
31
32 if (!empty($productsMappedToRemove))
33 Vk\Map::removeProductMapping($productsMappedToRemove, $this->exportId);
34
35
36 $productsFromVk = Vk\Api\ApiHelper::extractItemsFromArray($productsFromVk, array("VK_ID"));
37 $productsFromVk = array_chunk($productsFromVk, Vk\Vk::MAX_EXECUTION_ITEMS); // max 25 items in execute()
38 foreach ($productsFromVk as $chunk)
39 {
40 $this->executer->executeMarketProductDelete(array(
41 "owner_id" => $this->vkGroupId,
42 "data" => $chunk,
43 "count" => count($chunk),
44 ));
45
46// abstract start position - only for continue export, not for rewind to position
47 if ($timer !== NULL && !$timer->check())
48 throw new TimeIsOverException("Timelimit for export is over", '1');
49 }
50
51// remove products from cache
52 $vkExportedData = new Vk\VkExportedData($this->exportId, 'PRODUCTS');
53 $vkExportedData->removeData();
54
55 return true;
56 }
57}