Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
productbatchconverter.php
1
<?php
2
namespace
Bitrix\Catalog\Update
;
3
4
use
Bitrix\Catalog\Config\State
;
5
use
Bitrix\Catalog\Product\Store\BatchBalancer\Balancer
;
6
use
Bitrix\Catalog\StoreProductTable
;
7
use
Bitrix\Main\Loader
;
8
use
Bitrix\Main\Localization\Loc
;
9
use
Bitrix\Main\Update\Stepper
;
10
18
class
ProductBatchConverter
extends
Stepper
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
{
28
return
self::FINISH_EXECUTION
;
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
}
Bitrix\Catalog\Config\State
Definition
state.php:21
Bitrix\Catalog\Product\Store\BatchBalancer\Balancer
Definition
balancer.php:14
Bitrix\Catalog\StoreProductTable
Definition
storeproduct.php:39
Bitrix\Catalog\Update\ProductBatchConverter
Definition
productbatchconverter.php:19
Bitrix\Catalog\Update\ProductBatchConverter\execute
execute(array &$option)
Definition
productbatchconverter.php:24
Bitrix\Catalog\Update\ProductBatchConverter\$moduleId
static $moduleId
Definition
productbatchconverter.php:22
Bitrix\Catalog\Update\ProductBatchConverter\getTitle
static getTitle()
Definition
productbatchconverter.php:60
Bitrix\Catalog\Update\ProductBatchConverter\PRODUCT_LIMIT
const PRODUCT_LIMIT
Definition
productbatchconverter.php:20
Bitrix\Main\Loader
Definition
loader.php:12
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Main\ORM\Data\DataManager\getList
static getList(array $parameters=array())
Definition
datamanager.php:441
Bitrix\Main\ORM\Data\DataManager\getCount
static getCount($filter=array(), array $cache=array())
Definition
datamanager.php:526
Bitrix\Main\Update\Stepper
Definition
stepper.php:27
Bitrix\Main\Update\Stepper\FINISH_EXECUTION
const FINISH_EXECUTION
Definition
stepper.php:34
Bitrix\Main\Update\Stepper\CONTINUE_EXECUTION
const CONTINUE_EXECUTION
Definition
stepper.php:33
Bitrix\Catalog\Update
Definition
adminfilteroption.php:2
modules
catalog
lib
update
productbatchconverter.php
Создано системой
1.10.0