1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
productsdelete.php
См. документацию.
1<?php
2
3namespace Bitrix\Sale\TradingPlatform\Vk\Feed\Data\Processors;
4
5use Bitrix\Sale\TradingPlatform\Vk\Api\ApiHelper;
6use Bitrix\Sale\TradingPlatform\Vk;
7use Bitrix\Sale\TradingPlatform\Timer;
8use Bitrix\Sale\TradingPlatform\TimeIsOverException;
9
15{
22 public function process($data = NULL, Timer $timer = NULL)
23 {
24 $apiHelper = new ApiHelper($this->exportId);
25
26 $productsFromVk = $apiHelper->getProductsFromVk($this->vkGroupId);
27 $productsMapped = Vk\Map::getMappedProducts($this->exportId);
28
29// remove from mapping products which not exist in VK
30 $productsMappedToRemove = array();
31 foreach ($productsMapped as $key => $productMapped)
32 {
33 if (!isset($productsFromVk[$productMapped["VK_ID"]]))
34 {
35 $productsMappedToRemove[] = array("VALUE_EXTERNAL" => $productMapped["VK_ID"]);
36 unset($productsMapped[$key]);
37 }
38 }
39// remove not exists in VK items
40 if (!empty($productsMappedToRemove))
41 Vk\Map::removeProductMapping($productsMappedToRemove, $this->exportId);
42
43// In delete procedure we not need http file upload.
44// It means that we can not limit max items by settings and using max possible count.
45 $productsMapped = array_chunk($productsMapped, Vk\Vk::MAX_EXECUTION_ITEMS); // max 25 items in execute()
46 foreach ($productsMapped as $chunk)
47 {
48 $resDelete = $this->executer->executeMarketProductDelete(array(
49 "owner_id" => $this->vkGroupId,
50 "data" => $chunk,
51 "count" => count($chunk),
52 ));
53
54 foreach ($resDelete as $res)
55 {
56 if ($res["flag_product_delete_result"])
57 $productsMappedToRemove[] = array("VALUE_EXTERNAL" => $res["VK_ID"]);
58 }
59
60 // remove success deleted items
61 if (!empty($productsMappedToRemove))
62 Vk\Map::removeProductMapping($productsMappedToRemove, $this->exportId);
63
64// abstract start position - only for continue export, not for rewind to position
65 if ($timer !== NULL && !$timer->check())
66 throw new TimeIsOverException("Timelimit for export is over", '1');
67 }
68
69// remove products from cache
70 $vkExportedData = new Vk\VkExportedData($this->exportId, 'PRODUCTS');
71 $vkExportedData->removeData();
72
73 return true;
74 }
75
76
77}
static removeProductMapping($values, $exportId, $flagKeys='')
Определения map.php:83
static getMappedProducts($exportId)
Определения map.php:394
const MAX_EXECUTION_ITEMS
Определения vk.php:33
$data['IS_AVAILABLE']
Определения .description.php:13
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$res
Определения filter_act.php:7
if(empty($signedUserToken)) $key
Определения quickway.php:257
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936