- Модуль: catalog
- Путь к файлу: ~/bitrix/modules/catalog/lib/v2/Integration/Landing/StoreV3Master.php
- Класс: BitrixCatalogv2IntegrationLandingStoreV3Master
- Вызов: StoreV3Master::getUnusedStoresList
static function getUnusedStoresList(): array
{
static $result = null;
if ($result === null)
{
if (!Loader::includeModule('landing') || !Loader::includeModule('crm'))
{
return [];
}
Rights::setGlobalOff();
$result = [];
$activeStoreIds = [];
$res = Site::getList([
'select' => ['ID'],
'filter' => [
'=TYPE' => 'STORE',
'=ACTIVE' => 'Y',
],
]);
while ($row = $res->fetch())
{
$activeStoreIds[] = $row['ID'];
}
if (!empty($activeStoreIds))
{
$storesInUse = [];
$filter = [
'>CNT' => self::MINIMAL_ORDERS_LIMIT,
'=TRADING_PLATFORM.CODE' => [],
];
foreach ($activeStoreIds as $siteId)
{
$filter['=TRADING_PLATFORM.CODE'][] = 'landing_' . $siteId;
}
$res = TradeBindingCollection::getList([
'select' => [
'CNT',
'TRADING_PLATFORM_CODE' => 'TRADING_PLATFORM.CODE',
],
'filter' => $filter,
'group' => 'TRADING_PLATFORM.CODE',
'runtime' => [new ExpressionField('CNT', 'COUNT(*)')],
]);
while ($row = $res->fetch())
{
if ($row['TRADING_PLATFORM_CODE'])
{
[, $siteId] = explode('_', $row['TRADING_PLATFORM_CODE']);
$storesInUse[] = $siteId;
}
}
$result = array_diff($activeStoreIds, $storesInUse);
}
Rights::setGlobalOn();
}
return $result;
}