Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
productbatchconverter.php
1<?php
3
10
19{
20 protected const PRODUCT_LIMIT = 100;
21
22 protected static $moduleId = 'catalog';
23
24 public function execute(array &$option): bool
25 {
26 if (!Loader::includeModule('catalog') || !State::isUsedInventoryManagement())
27 {
29 }
30
31 $option["count"] = StoreProductTable::getCount();
32 $option["steps"] ??= 0;
33 $option["lastProductId"] ??= 0;
34 $storeProductDataRaw = StoreProductTable::getList([
35 'limit' => self::PRODUCT_LIMIT,
36 'select' => ['PRODUCT_ID'],
37 'filter' => [
38 '>PRODUCT_ID' => (int)$option["lastProductId"],
39 ],
40 'group' => ['PRODUCT_ID'],
41 'order' => ['PRODUCT_ID' => 'ASC'],
42 ]);
43
44 $batchCount = 0;
45 while ($storeProduct = $storeProductDataRaw->fetch())
46 {
47 $storeProductId = $storeProduct['PRODUCT_ID'];
48 $option["lastProductId"] = $storeProductId;
49
50 (new Balancer($storeProductId))->fill();
51
52 $batchCount++;
53 }
54
55 $option["steps"] += $batchCount;
56
57 return $batchCount === 0 ? self::FINISH_EXECUTION : self::CONTINUE_EXECUTION;
58 }
59
60 public static function getTitle()
61 {
62 return Loc::getMessage('CATALOG_PRODUCT_BATCH_CONVERTER_TITLE');
63 }
64}
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
static getList(array $parameters=array())
static getCount($filter=array(), array $cache=array())